:root {
  --bg: #12131A;
  --panel: #191B24;
  --elevated: #22242F;
  --border: #2A2C38;
  --accent: #7C5CFF;
  --accent-soft: #7C5CFF33;
  --gold: #F2B705;
  --text: #EDEDF2;
  --muted: #8B8D9B;
  --success: #3ED598;
  --danger: #FF6B6B;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ---------- Auth screen ---------- */
.auth-body { overflow: auto; height: auto; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-wrap { display: flex; gap: 56px; align-items: center; max-width: 900px; flex-wrap: wrap; justify-content: center; }
.auth-brand { max-width: 340px; }
.logo-mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #4D2FD9);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; letter-spacing: -0.5px; margin-bottom: 18px;
}
.auth-brand h1 { font-size: 34px; margin: 0 0 12px; letter-spacing: -0.5px; }
.auth-brand p { color: var(--muted); line-height: 1.6; font-size: 15px; }

.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 340px; }
.tabs { display: flex; gap: 4px; background: var(--elevated); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tab { flex: 1; background: none; border: none; color: var(--muted); padding: 9px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.tab.active { background: var(--accent); color: white; }

.auth-form label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 6px; }
.auth-form input, .auth-form select { width: 100%; background: var(--elevated); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.auth-form input:focus, .auth-form select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn-primary { margin-top: 18px; width: 100%; background: var(--accent); color: white; border: none; padding: 11px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; }
.btn-primary:hover { background: #6c4bee; }
.btn-primary.small { width: auto; margin-bottom: 14px; padding: 8px 14px; font-size: 13px; }
.btn-secondary { background: var(--elevated); color: var(--text); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; line-height: 1.5; }
.hidden { display: none !important; }

/* ---------- App layout ---------- */
.app { display: flex; height: 100vh; }

.sidebar { width: 300px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-top { padding: 16px; border-bottom: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 15px; flex-shrink: 0;
}
.me-name { font-weight: 700; font-size: 14.5px; }
.me-balance { color: var(--gold); font-size: 12.5px; font-weight: 600; }
.top-actions { display: flex; gap: 8px; }
.top-actions button { flex: 1; background: var(--elevated); border: 1px solid var(--border); color: var(--text); padding: 8px 0; border-radius: 10px; cursor: pointer; font-size: 15px; }
.top-actions button:hover { background: var(--accent-soft); }

.contacts { flex: 1; overflow-y: auto; }
.contact { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.contact:hover, .contact.active { background: var(--elevated); }
.contact-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.badge-verified { color: var(--accent); font-size: 12px; }
.contact-sub { color: var(--muted); font-size: 12px; }

.chat { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; align-items: center; gap: 8px; min-height: 24px; }
.empty-hint { color: var(--muted); font-weight: 400; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }

.msg { max-width: 60%; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--elevated); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.msg-item { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.15); padding: 8px 10px; border-radius: 10px; margin-top: 4px; }
.msg-item .emoji { font-size: 22px; }

.composer { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.composer button[type="button"] { background: var(--elevated); border: 1px solid var(--border); border-radius: 10px; width: 42px; font-size: 18px; cursor: pointer; }
.composer input { flex: 1; background: var(--elevated); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: 12px; font-size: 14.5px; }
.composer input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.composer button[type="submit"] { background: var(--accent); color: white; border: none; padding: 0 20px; border-radius: 12px; font-weight: 700; cursor: pointer; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 340px; max-height: 82vh; overflow-y: auto; }
.modal-card.wide { width: 560px; }
.modal-card h3 { margin: 0 0 16px; }
.modal-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.modal-card input, .modal-card select { width: 100%; background: var(--elevated); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.item-card { background: var(--elevated); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.item-card .emoji { font-size: 34px; }
.item-card .name { font-weight: 700; font-size: 13.5px; margin: 8px 0 2px; }
.item-card .type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.item-card .price { color: var(--gold); font-weight: 700; font-size: 13px; margin-top: 6px; }
.item-card button { margin-top: 10px; width: 100%; background: var(--accent); color: white; border: none; padding: 7px; border-radius: 8px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.item-card .seller { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* ---------- Badges ---------- */
.badge-creator { color: var(--gold); font-size: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.creator { background: #F2B70533; color: var(--gold); }

/* ---------- Chat buttons (сценарии ботов) ---------- */
.msg-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-buttons button { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: inherit; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer; font-weight: 600; }
.msg.in .msg-buttons button { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.msg-buttons button:hover { filter: brightness(1.15); }

/* ---------- Bot constructor ---------- */
.constructor-list { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.scene-card { background: var(--elevated); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.scene-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.scene-trigger { flex: 1; background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 13.5px; font-weight: 600; }
.scene-remove { background: none; border: none; color: var(--danger); font-size: 16px; cursor: pointer; }
.scene-text { width: 100%; min-height: 60px; background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 13.5px; resize: vertical; font-family: inherit; }
.scene-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.scene-buttons input { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 5px 9px; border-radius: 999px; font-size: 12.5px; width: 120px; }
.scene-buttons .scene-btn-wrap { display: flex; align-items: center; gap: 4px; }
.scene-buttons .scene-btn-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; }
.btn-secondary.small { padding: 6px 12px; font-size: 12.5px; }

@media (max-width: 720px) {
  .sidebar { width: 92px; }
  .me-name, .me-balance { display: none; }
  .contact-sub { display: none; }
  .modal-card.wide { width: 92vw; }
  .msg { max-width: 82%; }
}

/* ---------- Кликабельный аватар/имя в сайдбаре ---------- */
.avatar-link, .me-name-link { text-decoration: none; color: inherit; }

/* ---------- Карточка подарка/NFT в стиле Telegram ---------- */
.gift-detail-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  width: 360px; max-width: 92vw; overflow: hidden; position: relative;
}
.gift-detail-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: rgba(0,0,0,.35); border: none; color: white; width: 28px; height: 28px;
  border-radius: 50%; cursor: pointer; font-size: 14px;
}
.gift-detail-hero {
  padding: 32px 20px 22px; text-align: center; color: white;
  background: linear-gradient(160deg, var(--hero-from, #3ED598), var(--hero-to, #1AA97A));
}
.gift-detail-media { font-size: 76px; line-height: 1; margin-bottom: 6px; }
.gift-detail-media video { width: 140px; height: 140px; object-fit: contain; }
.gift-detail-title { font-size: 20px; font-weight: 800; }
.gift-detail-subtitle { font-size: 13.5px; opacity: .9; margin-top: 2px; }
.gift-detail-table { width: 100%; border-collapse: collapse; }
.gift-detail-table td { padding: 10px 20px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.gift-detail-table td:first-child { color: var(--muted); width: 40%; }
.gift-detail-table .rarity-chip { background: var(--elevated); color: var(--muted); font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.gift-detail-actions { display: flex; gap: 8px; padding: 14px 20px 0; }
.gift-detail-actions button { flex: 1; padding: 9px; border-radius: 10px; font-weight: 700; font-size: 13px; cursor: pointer; border: none; }
.gift-detail-actions .upgrade-btn { background: var(--accent); color: white; }
.gift-detail-actions .sell-btn { background: var(--elevated); color: var(--text); border: 1px solid var(--border); }

/* ---------- Меню "Подарить" ---------- */
.item-card .gift-thumb { width: 100%; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 10px; margin-bottom: 6px; overflow: hidden; }
.item-card .gift-thumb video { width: 100%; height: 100%; object-fit: cover; }
.item-card .gift-thumb .emoji-big { font-size: 40px; }

/* ---------- Сообщение с прикреплённым подарком (кликабельное) ---------- */
.msg-item { cursor: pointer; }
.msg-item:hover { filter: brightness(1.1); }

/* ---------- Профиль ---------- */
.profile-body { overflow-y: auto; height: auto; min-height: 100vh; }
.profile-header { max-width: 640px; margin: 0 auto; padding: 24px 20px; text-align: center; }
.profile-avatar-big { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 800; color: white; }
.profile-name { font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; }
.profile-bio { color: var(--muted); font-size: 13.5px; margin-top: 6px; max-width: 420px; margin-left: auto; margin-right: auto; }
.profile-tabs { display: flex; justify-content: center; gap: 4px; margin: 18px auto 0; background: var(--elevated); border-radius: 10px; padding: 4px; max-width: 260px; }
.profile-tabs button { flex: 1; background: none; border: none; color: var(--muted); padding: 8px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }
.profile-tabs button.active { background: var(--accent); color: white; }
.profile-gifts-grid { max-width: 640px; margin: 20px auto; padding: 0 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 12px; }
