/* ================= Easy Vibe Code — дизайн-система ================= */

:root {
  --accent: #8fb6ff;
  --accent-2: #a98bff;
  --accent-3: #57e0c8;
  --void: #0b0e15;
  --ink: #e8ecf5;
  --mute: #98a2b8;
  --dim: #667089;
  --glass: rgba(20, 25, 36, 0.55);
  --glass-strong: rgba(22, 28, 40, 0.82);
  --line: rgba(140, 160, 200, 0.16);
  --ok: #5fd39a;
  --warn: #e6b455;
  --err: #f07a7a;
  --radius: 18px;
  --radius-sm: 12px;
  --blur: 22px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --bg-dim: 0.55;
  --pad: 18px;
  --gap: 14px;
  --font-size: 15px;
}

/* Плотность */
body[data-density="compact"] { --pad: 12px; --gap: 10px; --font-size: 14px; }
body[data-density="comfy"] { --pad: 24px; --gap: 20px; --font-size: 16px; }

/* Темы */
body[data-theme="aurora"] {
  --void: #0a1512;
  --glass: rgba(16, 34, 30, 0.55);
  --glass-strong: rgba(18, 40, 35, 0.82);
  --accent: #5fe0b0;
  --accent-2: #4fc8e0;
  --accent-3: #b8f06a;
}
body[data-theme="midnight"] {
  --void: #070a12;
  --glass: rgba(14, 20, 34, 0.62);
  --glass-strong: rgba(14, 20, 34, 0.88);
  --accent: #7aa2ff;
  --accent-2: #6f7cff;
}
body[data-theme="sand"] {
  --void: #171310;
  --ink: #f3ece2;
  --mute: #b6a894;
  --dim: #8a7d6b;
  --glass: rgba(34, 28, 22, 0.55);
  --glass-strong: rgba(36, 30, 23, 0.85);
  --accent: #e0b077;
  --accent-2: #d98f6a;
  --accent-3: #e6d08a;
  --line: rgba(220, 190, 150, 0.18);
}
body[data-theme="contrast"] {
  --void: #000000;
  --glass: rgba(0, 0, 0, 0.82);
  --glass-strong: rgba(0, 0, 0, 0.94);
  --ink: #ffffff;
  --mute: #c9ced8;
  --line: rgba(255, 255, 255, 0.28);
  --accent: #ffe066;
  --accent-2: #ff9f43;
  --accent-3: #6ee7ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--ink);
  font: var(--font-size)/1.55 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

#bg { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; z-index: 0; display: block; }
#bg-shade { position: fixed; inset: 0; z-index: 0; background: var(--void); opacity: calc(1 - var(--bg-dim)); pointer-events: none; }
#bg-vignette {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, transparent 40%, rgba(0,0,0,0.45) 100%);
}

.hidden { display: none !important; }
.muted { color: var(--mute); }
.small { font-size: 12.5px; }
.error { color: var(--err); margin-top: 8px; }
code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }

/* ------------------------------ Стекло ------------------------------ */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
  box-shadow: var(--shadow);
}

/* ------------------------------ Бренд ------------------------------ */
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand-lg { font-size: 20px; }
.brand-logo { width: 34px; height: 34px; filter: drop-shadow(0 4px 14px rgba(120,150,255,0.35)); }
.brand-name { letter-spacing: 0.2px; }
.brand-name b { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ------------------------------ Логин ------------------------------ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(80% 60% at 50% 30%, rgba(10,14,24,0.35), rgba(4,6,10,0.78));
  backdrop-filter: blur(6px);
}
.login-card { width: min(420px, 100%); padding: 26px; animation: pop-in 0.5s cubic-bezier(.2,.9,.3,1.2); }
.login-card p { margin: 10px 0 18px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--mute); margin-bottom: 5px; }

/* ------------------------------ Ввод ------------------------------ */
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(8, 11, 18, 0.55);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  background: rgba(8, 11, 18, 0.75);
}
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13.5px; }
.check input { width: auto; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input[type="range"] { width: 130px; padding: 0; }
.inline input[type="color"] { width: 42px; height: 34px; padding: 2px; }
.inline select { width: auto; }
.hidden-input { display: none; }

/* ------------------------------ Кнопки ------------------------------ */
.btn {
  position: relative; overflow: hidden;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .16s cubic-bezier(.2,.9,.3,1.2), filter .16s, background .16s, box-shadow .16s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #0a0e16;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn.danger { color: #ffb3b3; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.28), transparent 45%);
  opacity: 0; transition: opacity .25s;
}
.btn:hover::after { opacity: 1; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: rgba(255,255,255,0.05); color: var(--ink); cursor: pointer;
  transition: transform .16s, background .16s, filter .16s;
}
.icon-btn:hover { transform: translateY(-1px); filter: brightness(1.2); }
.icon-btn:active { transform: scale(0.95); }

.chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.045); color: var(--mute); font: inherit; font-size: 12.5px;
  cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .18s, border-color .18s, transform .16s, background .18s;
}
.chip:hover { color: var(--ink); border-color: var(--accent); transform: translateY(-1px); }

/* ------------------------------ Каркас ------------------------------ */
#app { position: relative; z-index: 1; display: flex; height: 100dvh; }

/* Правая панель (вкладки справа) */
.rail {
  order: 2;
  width: 240px; flex: none;
  margin: 14px 14px 14px 0;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
  box-shadow: var(--shadow);
}
.rail-top { display: flex; align-items: center; gap: 11px; }
.rail-logo { width: 38px; height: 38px; filter: drop-shadow(0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent)); }
.rail-brand { display: flex; flex-direction: column; line-height: 1.15; font-weight: 700; }
.rail-brand b { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.railnav { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.railbtn {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--mute);
  font: inherit; font-weight: 600; cursor: pointer; text-align: left;
  transition: background .2s, color .2s, transform .18s, border-color .2s;
}
.railbtn i { font-style: normal; font-size: 16px; width: 20px; display: inline-block; text-align: center; }
.railbtn:hover { color: var(--ink); background: rgba(255,255,255,0.05); transform: translateX(-2px); }
.railbtn.active {
  color: var(--ink);
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 26%, transparent), color-mix(in srgb, var(--accent-2) 18%, transparent));
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent), 0 8px 24px color-mix(in srgb, var(--accent) 18%, transparent);
}
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.rail-user {
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,0.04);
}
.rail-user b { color: var(--accent); font-weight: 600; }

.topbar-mobile { display: none; }

#stage { order: 1; flex: 1; min-width: 0; position: relative; padding: 14px; }
.panel { display: none; height: 100%; overflow-y: auto; padding-right: 4px; }
.panel.active { display: block; animation: view-in .42s cubic-bezier(.2,.9,.3,1); }
#panel-chat.active { display: flex; flex-direction: column; }
@keyframes view-in { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(12px); } to { opacity: 1; transform: none; } }

/* ------------------------------ Карточки ------------------------------ */
.glass.card { padding: var(--pad); margin-bottom: var(--gap); }
.card-title { font-weight: 700; margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stat {
  padding: 15px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); position: relative; overflow: hidden;
  animation: view-in .5s cubic-bezier(.2,.9,.3,1) backwards;
}
.stat:nth-child(2) { animation-delay: .05s; } .stat:nth-child(3) { animation-delay: .1s; }
.stat:nth-child(4) { animation-delay: .15s; } .stat:nth-child(5) { animation-delay: .2s; }
.stat .k { color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; }
.stat .v { font-size: 22px; font-weight: 750; margin-top: 3px; }
.stat .sub { color: var(--mute); font-size: 12px; }
.stat .bar { height: 5px; border-radius: 4px; background: rgba(255,255,255,0.08); margin-top: 9px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s cubic-bezier(.2,.9,.3,1); }

/* ------------------------------ Чат ------------------------------ */
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 4px 12px; scroll-behavior: smooth; }

.empty-hint { max-width: 660px; margin: 5vh auto 0; text-align: center; animation: view-in .5s ease; }
.empty-hint h2 { margin: 0 0 8px; font-weight: 750; font-size: 26px; }
.empty-hint p { color: var(--mute); margin: 0 0 18px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.suggestions .chip { white-space: normal; text-align: left; max-width: 320px; }

.msg { max-width: min(780px, 94%); margin: 12px 0; animation: msg-in .45s cubic-bezier(.2,.9,.3,1) backwards; }
@keyframes msg-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.msg .bubble {
  padding: 13px 16px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); overflow-wrap: break-word;
  position: relative;
}
.msg.user { margin-left: auto; }
.msg.user .bubble {
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 92%, transparent), color-mix(in srgb, var(--accent-2) 92%, transparent));
  color: #0a0e16; border-color: transparent; font-weight: 500;
  box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 25%, transparent);
}
.msg.assistant .bubble.streaming::after {
  content: ""; display: inline-block; width: 8px; height: 17px; margin-left: 3px;
  background: var(--accent); border-radius: 2px; vertical-align: text-bottom;
  animation: caret .9s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.msg.assistant .bubble p { margin: 0 0 9px; } .msg.assistant .bubble p:last-child { margin: 0; }
.msg.assistant .bubble ul { margin: 6px 0; padding-left: 20px; }
.msg.assistant .bubble pre {
  background: rgba(5, 8, 13, 0.85); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; overflow-x: auto; font-size: 13px; margin: 9px 0;
}
.msg.assistant .bubble pre code { background: none; padding: 0; }
.msg.assistant .bubble a { color: var(--accent); }

.tool-card {
  margin: 9px 0 9px 10px; max-width: min(730px, 92%);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.035); font-size: 13px; overflow: hidden;
  animation: msg-in .4s cubic-bezier(.2,.9,.3,1) backwards;
}
.tool-head { display: flex; align-items: center; gap: 9px; padding: 9px 13px; cursor: pointer; color: var(--mute); }
.tool-head .tool-name { color: var(--accent); font-weight: 700; }
.tool-head .tool-args { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card.ok .tool-name { color: var(--ok); } .tool-card.fail .tool-name { color: var(--err); }
.tool-card pre { margin: 0; padding: 0 13px 11px; max-height: 260px; overflow: auto; white-space: pre-wrap; color: var(--mute); display: none; }
.tool-card.open pre { display: block; }
.spinner { width: 13px; height: 13px; flex: none; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing-dots { color: var(--dim); letter-spacing: 3px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.chat-input { display: flex; gap: 9px; align-items: flex-end; padding: 10px; border-radius: var(--radius); }
.chat-input textarea { resize: none; max-height: 170px; border: none; background: transparent; padding: 9px 4px; }
.send-btn { height: 42px; min-width: 54px; font-size: 17px; }

.attach-strip, .file-strip { display: flex; gap: 9px; flex-wrap: wrap; padding: 8px 2px; }
.attach { position: relative; display: flex; align-items: center; gap: 9px; padding: 7px 11px 7px 7px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255,255,255,0.05); font-size: 12.5px; max-width: 250px; }
.attach img { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; }
.attach .icon { width: 36px; height: 36px; display: grid; place-items: center; font-size: 18px; }
.attach .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .rm { border: none; background: none; color: var(--err); cursor: pointer; font-size: 15px; }

.file-chip {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px;
  border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, rgba(255,255,255,0.03));
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 13.5px;
  transition: transform .18s, background .18s;
}
.file-chip:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--accent) 20%, rgba(255,255,255,0.03)); }
.file-chip .ico { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #0a0e16; font-size: 16px; }
.file-chip .meta { display: flex; flex-direction: column; }
.file-chip .meta b { font-weight: 700; } .file-chip .meta span { color: var(--mute); font-weight: 400; font-size: 11.5px; }

/* Статистика ответа */
.msg-stats { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.stat-pill {
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--mute);
  animation: view-in .4s ease backwards;
}

/* ------------------------------ Задачи ------------------------------ */
.tasks { display: flex; flex-direction: column; gap: 6px; }
.task { display: flex; gap: 10px; align-items: baseline; padding: 8px 11px; border-radius: 10px; background: rgba(255,255,255,0.035); font-size: 13px; }
.task .t { color: var(--dim); font-size: 11.5px; flex: none; width: 92px; }
.task .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .dd { color: var(--mute); font-size: 11.5px; }

/* ------------------------------ Проекты ------------------------------ */
.projects { display: grid; gap: var(--gap); }
.project {
  padding: var(--pad); border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); animation: view-in .45s cubic-bezier(.2,.9,.3,1) backwards;
  transition: transform .2s, border-color .2s;
}
.project:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.project-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.project-name { font-weight: 700; font-size: 16px; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650; border: 1px solid var(--line); color: var(--mute); }
.badge.running { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.badge.failed { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.badge.starting { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge.type-bot { color: #7fd0a0; } .badge.type-plugin { color: #c0a7ff; } .badge.type-web { color: #7fb3d0; }
.badge.owner { color: var(--accent); }

/* ------------------------------ Подписка ------------------------------ */
.sub-badge {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
}
.sub-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sub-line #sub-plan { font-weight: 700; font-size: 13px; }
.sub-line #sub-left { color: var(--mute); font-size: 11.5px; }
.sub-badge .usage-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.09); overflow: hidden; }
.sub-badge .usage-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s cubic-bezier(.2,.9,.3,1); }
.sub-badge .usage-bar i.warn { background: linear-gradient(90deg, #b08a3a, #e0a94a); }
.sub-badge .usage-bar i.full { background: linear-gradient(90deg, #a34a4a, #e06060); }
.sub-badge.expired { border-color: color-mix(in srgb, var(--err) 55%, transparent); }

.plan-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; border: 1px solid currentColor;
}
.plan-select { width: auto; padding: 6px 10px; font-size: 12.5px; }

/* ------------------------------ История чатов ------------------------------ */
.chat-topbar { display: flex; align-items: center; gap: 10px; padding: 2px 2px 8px; }
.chat-topbar #chat-quota { flex: 1; text-align: right; }
.history-drawer {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 40vh; overflow-y: auto;
  padding: 10px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--glass-strong); backdrop-filter: blur(var(--blur));
  animation: view-in .28s cubic-bezier(.2,.9,.3,1);
}
.history-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  transition: background .18s, border-color .18s;
}
.history-item:hover { background: rgba(255,255,255,0.06); }
.history-item.active { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.history-item .htitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.history-item .hmeta { color: var(--dim); font-size: 11.5px; flex: none; }
.history-item .hdel { border: none; background: none; color: var(--err); cursor: pointer; font-size: 14px; padding: 0 2px; }
.history-empty { color: var(--mute); font-size: 13px; padding: 8px; text-align: center; }

/* ------------------------------ Лимиты ------------------------------ */
#limits-hero { display: grid; gap: 12px; }
.limits-plan {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--plan-color, var(--accent)) 45%, transparent);
  background: color-mix(in srgb, var(--plan-color, var(--accent)) 10%, rgba(255,255,255,0.02));
}
.limits-plan .big { font-size: 26px; font-weight: 800; color: var(--plan-color, var(--accent)); }
.limits-plan .cap { color: var(--mute); font-size: 13px; }
.limits-ring {
  --p: 0; width: 92px; height: 92px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--plan-color, var(--accent)) calc(var(--p) * 1%), rgba(255,255,255,0.08) 0);
  display: grid; place-items: center; position: relative;
}
.limits-ring::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--glass-strong);
}
.limits-ring span { position: relative; font-weight: 800; font-size: 17px; }
.limits-rows { display: grid; gap: 8px; }
.limits-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 11px; background: rgba(255,255,255,0.035); font-size: 13.5px; }
.limits-row .k { color: var(--mute); flex: 1; }
.limits-row .v { font-weight: 700; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.plan-card {
  padding: 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: rgba(255,255,255,0.03); transition: transform .2s, border-color .2s;
}
.plan-card:hover { transform: translateY(-2px); }
.plan-card.current { border-color: currentColor; box-shadow: 0 0 0 1px currentColor inset; }
.plan-card .pn { font-weight: 800; font-size: 15px; }
.plan-card .pl { color: var(--mute); font-size: 12.5px; margin-top: 3px; }
.project-meta { color: var(--dim); font-size: 12.5px; margin-top: 7px; font-family: "JetBrains Mono", Consolas, monospace; word-break: break-all; }
.project-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 13px; }
.project-link { color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 600; }

/* ------------------------------ Админ ------------------------------ */
.accounts, .inventory, .sshlog, .users { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.user-row, .inv-row, .ssh-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 11px; background: rgba(255,255,255,0.035); font-size: 13px; }
.user-row .nm { font-weight: 700; } .user-row .grow { flex: 1; }
.inv-row .p { flex: 1; font-family: "JetBrains Mono", Consolas, monospace; word-break: break-all; }
.inv-row .sz { color: var(--mute); font-size: 12px; }
.ssh-row.fail { border-left: 3px solid var(--err); }
.ssh-row.ok { border-left: 3px solid var(--ok); }
.ssh-row .time { color: var(--dim); font-size: 11.5px; width: 78px; flex: none; }
.ssh-row .ip { font-family: monospace; }

/* ------------------------------ Терминал ------------------------------ */
.term { padding: 0; overflow: hidden; }
.term-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--mute); font-size: 13px; flex-wrap: wrap; }
.term-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.term-out { margin: 0; padding: 13px; height: min(340px, 40vh); overflow-y: auto; font: 12.5px/1.55 "JetBrains Mono", Consolas, monospace; color: var(--mute); white-space: pre-wrap; word-break: break-word; }
.term-out .cmd { color: var(--accent); } .term-out .err { color: #f2a3a3; }
.term-in { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border-top: 1px solid var(--line); }
.term-in .prompt { color: var(--accent); font-family: monospace; }
.term-in input { border: none; background: transparent; padding: 6px 0; font-family: monospace; }

/* ------------------------------ Шейдеры ------------------------------ */
.shader-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; margin-top: 13px; }
.shader-tile { position: relative; aspect-ratio: 16/10; border-radius: var(--radius-sm); border: 1px solid var(--line); overflow: hidden; cursor: pointer; background: #0b0d11; transition: transform .2s, border-color .2s; }
.shader-tile:hover { transform: translateY(-3px) scale(1.02); border-color: var(--accent); }
.shader-tile canvas { width: 100%; height: 100%; display: block; }
.shader-tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 7px; font-size: 10.5px; background: linear-gradient(transparent, rgba(0,0,0,0.8)); color: #e7ecf3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shader-tile.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 10px 26px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ------------------------------ Модалка ------------------------------ */
.modal-card { width: min(900px, 100%); max-height: 88vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; animation: pop-in .4s cubic-bezier(.2,.9,.3,1.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-body { padding: 13px 15px; overflow-y: auto; }
.modal-body pre.logs { margin: 0; font: 12.5px/1.55 "JetBrains Mono", Consolas, monospace; white-space: pre-wrap; word-break: break-word; color: var(--mute); }
.editor { width: 100%; min-height: 46vh; font: 13px/1.5 "JetBrains Mono", Consolas, monospace; white-space: pre; overflow: auto; }
.tree { font-size: 13.5px; }
.tree .item { padding: 4px 7px; border-radius: 7px; cursor: pointer; display: flex; gap: 8px; }
.tree .item:hover { background: rgba(255,255,255,0.07); }
.tree .item.file { color: var(--mute); }
.tree .item .size { margin-left: auto; color: var(--dim); font-size: 11.5px; }

/* ------------------------------ Тосты ------------------------------ */
#toasts { position: fixed; right: 14px; bottom: 14px; z-index: 80; display: flex; flex-direction: column; gap: 9px; max-width: min(360px, calc(100vw - 28px)); }
.toast { padding: 11px 15px; border-radius: var(--radius-sm); background: var(--glass-strong); border: 1px solid var(--line); backdrop-filter: blur(var(--blur)); font-size: 13.5px; animation: toast-in .3s cubic-bezier(.2,.9,.3,1.2); }
.toast.err { border-color: color-mix(in srgb, var(--err) 55%, transparent); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } }

/* ------------------------------ Моушн-режимы ------------------------------ */
body[data-motion="soft"] * { animation-duration: .55s !important; }
body[data-motion="soft"] .btn:hover, body[data-motion="soft"] .project:hover { transform: none; }
body[data-motion="off"] *, body[data-motion="off"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------ Мобильный ------------------------------ */
@media (max-width: 860px) {
  #app { flex-direction: column; overflow: hidden; }
  /* Рельс-панель на телефоне не нужна, но её навигация переносится вниз. */
  .rail {
    display: contents;
  }
  .rail-top, .rail-brand, .rail-bottom, .rail-user, #shader-chip { display: none; }
  .topbar-mobile {
    display: flex; align-items: center; gap: 10px; flex: none;
    padding: 10px 13px; margin: 8px 8px 0;
    background: var(--glass-strong); border: 1px solid var(--line); border-radius: var(--radius);
    backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  }
  .topbar-mobile .brand-logo { width: 28px; height: 28px; }
  .topbar-mobile .brand-name { font-weight: 700; flex: 1; font-size: 15px; }
  .topbar-mobile .user-chip { font-size: 11.5px; padding: 5px 10px; }

  #stage {
    order: 1; flex: 1; min-height: 0;
    padding: 8px; padding-bottom: 0;
  }
  .panel { padding-bottom: 4px; }
  .msg { max-width: 100%; }
  .tool-card { margin-left: 0; max-width: 100%; }
  .term-out { height: 36vh; }
  .shader-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }

  /* Нижняя навигация вкладок */
  .railnav {
    order: 3; flex: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    flex-direction: row; gap: 2px; margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--glass-strong); border-top: 1px solid var(--line);
    backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
    justify-content: space-around;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  }
  .railbtn {
    flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px;
    font-size: 10.5px; text-align: center; transform: none !important;
    border-radius: 12px;
  }
  .railbtn i { font-size: 16px; }
  .railbtn.active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
  /* Нижняя навигация перекрывает контент — добавляем отступ чату и панелям */
  #panel-chat.active { padding-bottom: 0; }
  .chat-input { margin-bottom: 64px; }
  .panel { padding-bottom: 64px; }
}
