:root {
  --bg: #0b0d12;
  --bg-soft: #12151d;
  --card: #161a24;
  --card-hover: #1c212e;
  --line: #232838;
  --text: #eef1f6;
  --muted: #8b93a7;
  --gold: #c9a24b;
  --accent: #c9a24b;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(201, 162, 75, 0.12), transparent 60%),
    radial-gradient(700px 500px at 0% 100%, rgba(63, 167, 184, 0.10), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.view {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), #8a6d2c);
  color: #1a1406; font-weight: 800; letter-spacing: 0.5px;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ---------- Home ---------- */
.home-main {
  flex: 1;
  overflow: hidden;
  padding: clamp(24px, 4vh, 52px) 28px clamp(20px, 3vh, 40px);
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.home-hero { margin-bottom: clamp(18px, 3.2vh, 38px); }
/* на низких экранах разрешаем мягкий скролл, чтобы ничего не обрезалось */
@media (max-height: 720px) { .home-main { overflow-y: auto; } }
.eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold);
  padding: 7px 14px; border-radius: 20px;
  background: rgba(201, 162, 75, 0.10);
  border: 1px solid rgba(201, 162, 75, 0.22);
}
.home-title {
  font-size: clamp(38px, 5.4vw, 62px);
  font-weight: 800; letter-spacing: -1.5px; line-height: 1.02;
  margin-top: 16px;
}
.home-title .grad {
  background: linear-gradient(100deg, var(--gold), #f3d488 45%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  background-size: 200% auto; animation: shimmer 4s linear infinite;
}
.home-title .reveal { display: inline-block; }
.home-sub { color: var(--muted); font-size: 17px; line-height: 1.55; margin-top: 14px; max-width: 560px; }
.home-sub b { color: var(--text); font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  flex: 1;
  min-height: 0;
  align-content: stretch;
  grid-auto-rows: minmax(190px, 1fr);
}

.proj-card {
  position: relative;
  background: linear-gradient(180deg, var(--card), #12151d);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(.2,.7,.2,1), border-color 0.28s, box-shadow 0.28s;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* вступительная анимация */
  opacity: 0; transform: translateY(24px);
  animation: cardIn 0.6s cubic-bezier(.2,.7,.2,1) forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes cardIn { to { opacity: 1; transform: none; } }

/* свечение от акцентного цвета */
.proj-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(420px 200px at 80% -20%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 70%);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.proj-card:hover {
  transform: translateY(-8px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  box-shadow: 0 24px 60px -20px color-mix(in srgb, var(--accent) 45%, transparent);
}
.proj-card:hover::before { opacity: 1; }

.proj-card .accent-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), transparent 85%);
}
.proj-card .card-mono {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 800; color: #14110a;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  box-shadow: 0 8px 24px -8px var(--accent);
  position: relative; z-index: 1;
}
.proj-card h3 { font-size: 24px; font-weight: 700; margin-top: 20px; position: relative; z-index: 1; }
.proj-card .tag { color: var(--muted); font-size: 14.5px; margin-top: 7px; position: relative; z-index: 1; }
.proj-card .enter {
  margin-top: auto; padding-top: 20px;
  font-size: 14px; font-weight: 600;
  color: var(--accent); display: flex; align-items: center; gap: 8px;
  position: relative; z-index: 1;
}
.proj-card .enter .arr { transition: transform 0.25s; display: inline-block; }
.proj-card:hover .enter .arr { transform: translateX(6px); }

/* ---------- Chat ---------- */
.chat-topbar { justify-content: space-between; }
.back-btn, .ghost-btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}
.back-btn { width: 40px; height: 40px; font-size: 20px; }
.ghost-btn { padding: 9px 14px; font-size: 13px; color: var(--muted); }
.ghost-btn:hover, .back-btn:hover { border-color: var(--accent); color: var(--text); }
.chat-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.chat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.chat-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.msg { display: flex; gap: 12px; max-width: 88%; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.bubble {
  padding: 13px 16px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.bot .bubble { background: var(--card); border: 1px solid var(--line); border-top-left-radius: 4px; white-space: normal; }
.msg.user .bubble { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000)); color: #14110a; font-weight: 500; border-top-right-radius: 4px; }
.msg.bot .bubble p { margin: 0 0 9px; }
.msg.bot .bubble p:last-child { margin-bottom: 0; }
.msg.bot .bubble ul, .msg.bot .bubble ol { margin: 6px 0 9px; padding-left: 22px; }
.msg.bot .bubble li { margin: 3px 0; }
.msg.bot .bubble strong { font-weight: 700; color: var(--accent); }
.msg.bot .bubble code { background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: 13px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.msg.bot .avatar { background: var(--bg-soft); border: 1px solid var(--line); color: var(--accent); }
.msg.user .avatar { background: var(--accent); color: #14110a; }

.empty-state { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; }
.empty-mono {
  width: 84px; height: 84px; border-radius: 24px; margin-bottom: 22px;
  display: grid; place-items: center; font-size: 38px; font-weight: 800; color: #14110a;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  box-shadow: 0 18px 50px -14px var(--accent);
}
.empty-state h2 { color: var(--text); font-size: 30px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
.empty-state p { font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 9px 14px; border-radius: 20px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: 0.15s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-2px); }

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* ---------- Composer ---------- */
.composer { border-top: 1px solid var(--line); padding: 16px 28px 20px; }
.composer-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 8px 8px 8px 16px;
  transition: border-color 0.15s;
}
.composer-inner:focus-within { border-color: var(--accent); }
#input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: inherit; font-size: 15px; resize: none;
  max-height: 160px; padding: 8px 0; line-height: 1.5;
}
.send-btn {
  width: 40px; height: 40px; flex-shrink: 0; border: none; cursor: pointer;
  border-radius: 12px; font-size: 19px; font-weight: 700;
  background: var(--accent); color: #14110a; transition: 0.15s;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.composer-hint { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 10px; max-width: 900px; margin-left: auto; margin-right: auto; }

/* ============ МОБИЛЬНАЯ АДАПТАЦИЯ ============ */
@media (max-width: 760px) {
  /* шапка: компактнее, прячем подписи */
  .topbar { padding: 12px 14px; gap: 10px; }
  .brand-sub { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  .user-chip { gap: 8px; }
  .user-chip .uname, .user-chip .uemail { display: none; }
  .ghost-btn { padding: 8px 11px; font-size: 12.5px; }
  .user-ava { width: 34px; height: 34px; }

  /* главный экран: естественная прокрутка, одна колонка */
  .home-main { overflow-y: auto; display: block; padding: 24px 16px 32px; }
  .home-hero { margin-bottom: 20px; }
  .home-title { font-size: clamp(32px, 8.5vw, 44px); margin-top: 12px; }
  .home-sub { font-size: 15.5px; margin-top: 12px; }
  .home-stats { gap: 20px; margin-top: 18px; }
  .stat b { font-size: 23px; }
  .stat span { font-size: 11.5px; }
  .grid { grid-template-columns: 1fr; gap: 14px; flex: initial; grid-auto-rows: auto; }
  .proj-card { min-height: 0; padding: 20px; }
  .proj-card .card-mono { width: 50px; height: 50px; font-size: 21px; border-radius: 14px; }
  .proj-card h3 { font-size: 20px; margin-top: 16px; }
  .proj-card .enter { padding-top: 16px; }

  /* чат */
  .chat-topbar { padding: 12px 14px; }
  .chat-main { padding: 18px 14px; gap: 14px; }
  .msg { max-width: 92%; }
  .bubble { font-size: 14.5px; padding: 12px 14px; }
  .empty-state { padding-top: 8vh; }
  .composer { padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  #input { font-size: 16px; } /* 16px — чтобы iOS не зумил поле */

  /* вход */
  .auth-card { padding: 24px; }
  .auth-form input { font-size: 16px; }

  /* админка */
  .admin-main { padding: 26px 16px; }
  .u-row { flex-wrap: wrap; gap: 12px; }
  .u-row .u-info { flex-basis: calc(100% - 60px); }
  .u-actions { width: 100%; }
  .act { flex: 1; text-align: center; }
}

@media (max-width: 420px) {
  .home-title { font-size: 32px; }
  .home-stats { gap: 16px; }
  .ghost-btn { padding: 7px 9px; font-size: 12px; }
}

/* тач-устройства: убираем 3D-наклон и свет за курсором (нет мыши) */
@media (hover: none), (pointer: coarse) {
  .proj-inner { transform: none !important; }
  .proj-card::after, .proj-card .shine { display: none; }
  .proj-card:active { transform: scale(0.985); }
}

/* ============ AUTH ============ */
.auth-body { overflow: auto; }
.auth-orb {
  position: fixed; border-radius: 50%; filter: blur(80px); opacity: 0.5;
  pointer-events: none; z-index: 0; animation: float 14s ease-in-out infinite;
}
.orb1 { width: 420px; height: 420px; background: rgba(201,162,75,0.35); top: -120px; right: -80px; }
.orb2 { width: 360px; height: 360px; background: rgba(63,167,184,0.30); bottom: -120px; left: -60px; animation-delay: -7s; }
@keyframes float { 0%,100% { transform: translateY(0) translateX(0); } 50% { transform: translateY(40px) translateX(20px); } }

.auth-wrap {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: grid; grid-template-columns: 1.1fr 0.9fr;
  align-items: center; gap: 40px;
  max-width: 1200px; margin: 0 auto; padding: 40px 32px;
}
.auth-hero { padding-right: 20px; }
.auth-brand { margin-bottom: 40px; }
.auth-brand .brand-name { font-size: 20px; }

.auth-title { font-size: clamp(38px, 6vw, 68px); font-weight: 800; line-height: 1.02; letter-spacing: -1.5px; }
.auth-title .line { display: block; }
.auth-title .grad {
  background: linear-gradient(100deg, var(--gold), #f3d488 45%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  background-size: 200% auto; animation: shimmer 4s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }

.auth-lead { color: var(--muted); font-size: 18px; line-height: 1.6; margin-top: 26px; max-width: 460px; }

.auth-rotator { margin-top: 30px; font-size: 17px; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.rot-words { position: relative; height: 1.4em; overflow: hidden; display: inline-grid; }
.rot-words b {
  color: var(--gold); font-weight: 700; grid-area: 1/1;
  animation: rotw 6s infinite; opacity: 0;
}
.rot-words b:nth-child(1) { animation-delay: 0s; }
.rot-words b:nth-child(2) { animation-delay: 2s; }
.rot-words b:nth-child(3) { animation-delay: 4s; }
@keyframes rotw {
  0% { opacity: 0; transform: translateY(100%); }
  6%,28% { opacity: 1; transform: translateY(0); }
  34%,100% { opacity: 0; transform: translateY(-100%); }
}

/* reveal animation */
.reveal { opacity: 0; transform: translateY(18px); animation: revealIn 0.7s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: var(--d, 0s); }
@keyframes revealIn { to { opacity: 1; transform: none; } }

/* card */
.auth-card {
  background: rgba(22, 26, 36, 0.7);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.seg { display: flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 24px; }
.seg-btn {
  flex: 1; padding: 10px; border: none; background: transparent; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600; border-radius: 9px; cursor: pointer; transition: 0.18s;
}
.seg-btn.active { background: var(--card-hover); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,0.3); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; }
.auth-form input {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; color: var(--text); font-family: inherit; font-size: 15px; transition: border-color 0.15s;
}
.auth-form input:focus { outline: none; border-color: var(--gold); }
.primary-btn {
  margin-top: 6px; padding: 14px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #ab8636); color: #14110a;
  font-family: inherit; font-size: 15px; font-weight: 700; transition: 0.15s;
}
.primary-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.form-msg { font-size: 13.5px; line-height: 1.45; max-height: 0; overflow: hidden; transition: max-height 0.25s; }
.form-msg.show { max-height: 100px; }
.form-msg.err { color: #ff8b8b; }
.form-msg.ok { color: #7fe0a8; }
.form-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 2px; }

@media (max-width: 880px) {
  .auth-wrap { grid-template-columns: 1fr; gap: 28px; padding: 36px 20px; }
  .auth-hero { padding-right: 0; text-align: center; }
  .auth-brand { justify-content: center; }
  .auth-lead, .auth-title { margin-left: auto; margin-right: auto; }
  .auth-rotator { justify-content: center; }
}

/* ============ HEADER USER ============ */
.user-chip { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip .uname { font-size: 14px; font-weight: 600; }
.user-chip .uemail { font-size: 12px; color: var(--muted); }
.user-ava { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--gold), #8a6d2c); color: #1a1406; display: grid; place-items: center; font-weight: 800; }

/* ============ ADMIN ============ */
.admin-main { flex: 1; overflow-y: auto; padding: 40px 28px; max-width: 980px; width: 100%; margin: 0 auto; }
.admin-section-title { font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 28px 0 14px; }
.u-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 12px;
}
.u-row .u-ava { width: 44px; height: 44px; border-radius: 11px; background: var(--bg-soft); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--gold); flex-shrink: 0; }
.u-row .u-info { flex: 1; min-width: 0; }
.u-row .u-name { font-weight: 600; }
.u-row .u-mail { font-size: 13px; color: var(--muted); }
.badge { font-size: 11px; padding: 4px 9px; border-radius: 20px; font-weight: 700; }
.badge.pending { background: rgba(201,162,75,0.15); color: var(--gold); }
.badge.approved { background: rgba(127,224,168,0.13); color: #7fe0a8; }
.badge.rejected { background: rgba(255,139,139,0.13); color: #ff8b8b; }
.badge.admin { background: rgba(120,160,255,0.14); color: #9bb4ff; }
.u-actions { display: flex; gap: 8px; flex-shrink: 0; }
.act { border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); border-radius: 9px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: 0.15s; }
.act:hover { transform: translateY(-1px); }
.act.approve:hover { border-color: #7fe0a8; color: #7fe0a8; }
.act.reject:hover { border-color: #ff8b8b; color: #ff8b8b; }
.act.del:hover { border-color: #ff8b8b; color: #ff8b8b; }
.admin-empty { color: var(--muted); padding: 14px 4px; }
.admin-link { text-decoration: none; }

/* ============ HOME — WOW UPGRADE ============ */
/* живой фон-аврора + зерно */
.bg-aurora {
  position: fixed; inset: -35%; z-index: 0; pointer-events: none; opacity: 0.6;
  background:
    conic-gradient(from 0deg at 50% 50%,
      transparent 0deg, rgba(201,162,75,0.07) 40deg, transparent 110deg,
      rgba(63,167,184,0.06) 200deg, transparent 270deg, rgba(201,162,75,0.05) 320deg, transparent 360deg);
  animation: auroraSpin 48s linear infinite;
  filter: blur(30px);
}
@keyframes auroraSpin { to { transform: rotate(360deg); } }
.noise {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.orb3 {
  width: 300px; height: 300px; background: rgba(201,162,75,0.16);
  top: 32%; left: 38%; filter: blur(100px); opacity: 0.45;
  animation: float 22s ease-in-out infinite; animation-delay: -4s;
}

/* герой: статы + анимированное подчёркивание акцентного слова */
.home-stats { display: flex; gap: 34px; margin-top: clamp(16px, 2.4vh, 30px); flex-wrap: wrap; }
.stat b {
  display: block; font-size: 28px; font-weight: 800; line-height: 1;
  background: linear-gradient(120deg, #f3d488, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; letter-spacing: 0.3px; }
.home-title .grad { position: relative; }
.home-title .grad::after {
  content: ''; position: absolute; left: 2px; right: 2px; bottom: -8px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: scaleX(0); transform-origin: left;
  animation: underlineIn 0.9s cubic-bezier(.2,.7,.2,1) 0.85s forwards;
}
@keyframes underlineIn { to { transform: scaleX(1); } }

/* карточки: 3D-наклон + свет за курсором + блик */
.proj-card { perspective: 1000px; }
.proj-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 0;
  opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(260px 260px at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--accent) 26%, transparent), transparent 62%);
}
.proj-card:hover::after { opacity: 1; }
.proj-inner {
  position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column;
  transform: rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg));
  transform-style: preserve-3d; transition: transform 0.3s cubic-bezier(.2,.7,.2,1);
}
.proj-card:hover .card-mono { transform: translateZ(34px); transition: transform 0.3s; }
.proj-card .shine {
  position: absolute; top: 0; bottom: 0; left: -90%; width: 55%; z-index: 2; pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.10), transparent);
  transform: skewX(-16deg);
}
.proj-card:hover .shine { animation: shineSweep 0.95s ease; }
@keyframes shineSweep { from { left: -90%; } to { left: 150%; } }

@media (prefers-reduced-motion: reduce) {
  .bg-aurora, .orb3, .proj-inner, .shine { animation: none !important; transition: none !important; }
}

/* ============ тонкий аккуратный скроллбар ============ */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.14) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 10px; border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(201,162,75,0.45); background-clip: padding-box; }

/* ============ ФИКС: никакого горизонтального выезда на мобиле ============ */
@media (max-width: 760px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .bg-aurora { inset: -10%; }
  .auth-orb { filter: blur(70px); }
  .orb1 { width: 280px; height: 280px; right: -70px; }
  .orb2 { width: 240px; height: 240px; left: -60px; }
  .orb3 { width: 200px; height: 200px; }
  /* всё контентное — строго в ширину экрана */
  .topbar, .home-main, .home-hero, .home-sub, .home-stats, .grid,
  .chat-main, .composer, .proj-card { max-width: 100%; min-width: 0; }
  .home-sub { width: auto; }
  /* шапка не переполняется */
  .topbar { flex-wrap: nowrap; overflow: hidden; }
  .brand { min-width: 0; flex-shrink: 1; }
  .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-chip { min-width: 0; flex-shrink: 0; }
}
@media (max-width: 430px) {
  .topbar { gap: 8px; }
  .brand { gap: 9px; }
  .ghost-btn { padding: 7px 9px; font-size: 11.5px; }
  .home-stats { gap: 14px; }
  .stat b { font-size: 21px; }
}

/* ============ АДМИНКА: вкладки + обучение ИИ ============ */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 22px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; width: fit-content; max-width: 100%; }
.admin-tab { border: none; background: transparent; color: var(--muted); font-family: inherit; font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 9px; cursor: pointer; transition: .18s; white-space: nowrap; }
.admin-tab.active { background: var(--card-hover); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.3); }

.kb-lead { color: var(--muted); font-size: 15px; line-height: 1.55; margin-bottom: 20px; max-width: 640px; }
.kb-lead b { color: var(--gold); }

.kb-projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 26px; }
.kb-proj { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; font-family: inherit; transition: .2s; }
.kb-proj:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.kb-proj.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.kb-proj-mono { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; color: #14110a; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000)); flex-shrink: 0; }
.kb-proj-info { display: flex; flex-direction: column; min-width: 0; }
.kb-proj-name { font-weight: 700; }
.kb-proj-sub { font-size: 12px; color: var(--muted); }

.kb-panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.kb-panel-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.kb-panel-head h3 { font-size: 20px; font-weight: 700; }
.kb-baseinfo { font-size: 12.5px; color: var(--muted); }

.kb-add { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 24px; }
.kb-add-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.kb-file-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--card-hover); border: 1px dashed var(--line); color: var(--text); font-size: 13.5px; font-weight: 600; padding: 9px 14px; border-radius: 10px; cursor: pointer; transition: .15s; }
.kb-file-btn:hover { border-color: var(--accent); color: var(--gold); }
.kb-filemsg { font-size: 12.5px; color: var(--muted); }
#kbText { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--text); font-family: inherit; font-size: 14.5px; line-height: 1.5; resize: vertical; min-height: 110px; }
#kbText:focus { outline: none; border-color: var(--accent); }
.kb-add-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.kb-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.kb-check input { width: 16px; height: 16px; accent-color: var(--gold); }
.kb-save { margin: 0; padding: 11px 20px; }

.kb-item { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.kb-item.prio { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.kb-item-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.kb-item-date { font-size: 12.5px; color: var(--muted); }
.kb-del { margin-left: auto; padding: 5px 11px; font-size: 12.5px; }
.kb-item-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; max-height: 220px; overflow-y: auto; color: var(--text); }

/* ============ таблицы в ответах ИИ ============ */
.msg.bot .bubble .md-table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; -webkit-overflow-scrolling: touch; }
.msg.bot .bubble table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: max-content; }
.msg.bot .bubble th, .msg.bot .bubble td { padding: 8px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.msg.bot .bubble th { background: rgba(201,162,75,.10); color: var(--gold); font-weight: 700; position: sticky; top: 0; }
.msg.bot .bubble tbody tr:last-child td { border-bottom: none; }
.msg.bot .bubble tbody tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.msg.bot .bubble td:not(:first-child) { color: var(--text); }

/* ============ действия под ответом ИИ + голос + тосты ============ */
.msg-content { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.msg-actions { display: flex; align-items: center; gap: 6px; padding-left: 4px; flex-wrap: wrap; }
.msg-spacer { flex: 1; min-width: 8px; }
.msg-act { background: transparent; border: 1px solid var(--line); color: var(--muted); font-family: inherit; font-size: 12px; padding: 5px 10px; border-radius: 8px; cursor: pointer; transition: .15s; line-height: 1; }
.msg-act:hover { border-color: var(--accent); color: var(--text); }
.msg-act.vote { padding: 5px 9px; font-size: 13px; }
.msg-act.vote.active { border-color: var(--accent); background: rgba(201,162,75,.14); }

.mic-btn { width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); border-radius: 12px; font-size: 16px; cursor: pointer; transition: .15s; }
.mic-btn:hover { border-color: var(--accent); color: var(--text); }
.mic-btn.rec { background: rgba(255,107,107,.16); border-color: #ff6b6b; color: #ff6b6b; animation: micpulse 1.1s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,107,.4); } 50% { box-shadow: 0 0 0 7px rgba(255,107,107,0); } }

#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(12px); background: var(--card-hover); color: var(--text); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Админка: аналитика + редактирование ============ */
.an-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.an-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.an-val { font-size: 26px; font-weight: 800; color: var(--gold); line-height: 1; }
.an-key { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.an-gap { display: flex; align-items: center; gap: 12px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.an-gap-proj { font-size: 12px; font-weight: 700; color: var(--gold); background: rgba(201,162,75,.10); padding: 3px 9px; border-radius: 20px; flex-shrink: 0; }
.an-gap-q { flex: 1; font-size: 14px; min-width: 0; }
.an-gap-date { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.kb-edit-area { width: 100%; background: var(--bg); border: 1px solid var(--accent); border-radius: 10px; padding: 11px 13px; color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.5; resize: vertical; min-height: 90px; }
