* {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:       #080808;
  --surface:  #111111;
  --surface2: #181818;
  --surface3: #1f1f1f;
  --accent:   #D4698A;
  --accent2:  #9B5CE8;
  --grad:      linear-gradient(135deg, #D4698A 0%, #9B5CE8 100%);
  --grad-glow: linear-gradient(135deg, rgba(212,105,138,0.18) 0%, rgba(155,92,232,0.18) 100%);
  --text:  #f2f2f2;
  --text2: #999999;
  --dim:   #555555;
  --muted: #2e2e2e;
  --border:    rgba(255,255,255,0.07);
  --border-hi: rgba(255,255,255,0.14);
  --r:  18px;
  --rs: 14px;
  --rx: 10px;
  --font:      -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

body { padding-bottom: 82px; }
#app { max-width: 480px; margin: 0 auto; }

/* ══════════════════════════════════════════
   USER CARD
══════════════════════════════════════════ */
.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  margin: 14px 14px 12px;
  padding: 0;
  position: relative;
  overflow: hidden;
}

/* Gradient top line */
.user-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad);
}

.user-card__top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 18px 16px;
}

.user-card__avatar {
  width: 58px; height: 58px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--grad);
  box-shadow: 0 4px 20px rgba(212,105,138,0.35);
}
.user-card__avatar span {
  font-size: 24px; font-weight: 800; color: #fff;
  font-family: var(--font);
}

.user-card__name {
  font-size: 19px; font-weight: 700;
  letter-spacing: -0.3px; color: var(--text);
}
.user-card__id {
  font-size: 11px; color: var(--dim); margin-top: 2px;
  font-family: var(--font-mono);
}

.user-card__balance {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 0 0 22px 22px;
}
.user-card__balance-left { display: flex; flex-direction: column; }

.balance-label {
  font-size: 10px; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600;
}
.balance-amount {
  display: flex; align-items: baseline; gap: 5px; margin-top: 3px;
}
.balance-num {
  font-size: 28px; font-weight: 800;
  font-family: var(--font-mono);
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sp-coin {
  font-size: 15px; font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.btn-buy {
  background: var(--grad);
  color: #fff; border: none;
  border-radius: 50px;
  padding: 11px 24px;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 18px rgba(212,105,138,0.4);
  white-space: nowrap;
}
.btn-buy:active { transform: scale(0.95); opacity: 0.85; }

/* ══════════════════════════════════════════
   SECTION TITLE
══════════════════════════════════════════ */
.section-title {
  font-size: 26px; font-weight: 800;
  padding: 18px 16px 12px;
  letter-spacing: -0.6px; color: var(--text);
}

/* ══════════════════════════════════════════
   SUB TABS
══════════════════════════════════════════ */
.sub-tabs {
  display: flex; gap: 6px;
  padding: 0 14px 14px;
  overflow-x: auto; scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tabs--4 .sub-tab { flex: 1; min-width: 0; }

.sub-tab {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  color: var(--dim);
  font-family: var(--font); font-size: 10px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.sub-tab.active {
  background: var(--grad-glow);
  border-color: rgba(212,105,138,0.45);
  color: var(--accent);
}
.sub-tab__icon { font-size: 17px; }

/* ══════════════════════════════════════════
   TAB & SUB CONTENT
══════════════════════════════════════════ */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp 0.22s ease; }
.sub-content { display: none; padding: 0 14px; }
#subcontent-favorites { padding: 0; }
.sub-content.active { display: block; animation: fadeUp 0.18s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.dark-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; margin-bottom: 10px;
}
.dark-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

.accent-card {
  background: var(--grad);
  color: #fff; border-radius: var(--r);
  padding: 18px; margin-bottom: 10px;
  box-shadow: 0 8px 28px rgba(155,92,232,0.25);
}
.accent-card h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.accent-card__btn {
  display: block; width: 100%; padding: 12px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--rx);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  color: #fff; cursor: pointer; text-align: center; margin-top: 8px;
  transition: opacity 0.15s;
}
.accent-card__btn:active { opacity: 0.75; }

.ref-link-box {
  background: rgba(0,0,0,0.2); border-radius: var(--rx);
  padding: 12px; font-size: 11px; word-break: break-all;
  margin-bottom: 8px; cursor: pointer; font-weight: 600;
  font-family: var(--font-mono);
}
.ref-link-box:active { background: rgba(0,0,0,0.35); }

/* ══════════════════════════════════════════
   USEFUL BOTS
══════════════════════════════════════════ */
.useful-bots { display: flex; gap: 10px; }
.useful-bot {
  flex: 1; background: rgba(0,0,0,0.25);
  border-radius: var(--rs); padding: 14px; text-align: center; cursor: pointer;
}
.useful-bot__icon { font-size: 36px; margin-bottom: 8px; }
.useful-bot__label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; line-height: 1.3; }

/* ══════════════════════════════════════════
   LISTS & STATS
══════════════════════════════════════════ */
.bullet-list { list-style: none; padding: 0; }
.bullet-list li {
  position: relative; padding: 5px 0 5px 16px;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.88); line-height: 1.5;
}
.bullet-list li::before { content: '•'; position: absolute; left: 0; font-weight: 900; }

.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: var(--text2); }
.stat-row span:last-child  { font-weight: 700; color: var(--text); }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state {
  text-align: center; color: var(--dim);
  padding: 50px 20px; font-size: 14px; line-height: 1.7;
}

/* ══════════════════════════════════════════
   FAQ
══════════════════════════════════════════ */
.faq-list { display: flex; flex-direction: column; gap: 6px; }
.faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--rs); cursor: pointer; transition: border-color 0.2s;
}
.faq-item.open { border-color: rgba(212,105,138,0.4); }
.faq-q {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; font-size: 13px; font-weight: 600;
}
.faq-arrow { font-size: 10px; color: var(--dim); transition: transform 0.25s; }
.faq-item.open .faq-arrow { transform: rotate(180deg); }
.faq-a {
  display: none; padding: 0 16px 14px;
  font-size: 13px; color: var(--text2); line-height: 1.6;
}
.faq-item.open .faq-a { display: block; }
.faq-footer {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 20px 0 8px;
}

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.link-accent { color: var(--accent); text-decoration: underline; font-size: 12px; }

.input-field {
  width: 100%; padding: 13px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--rs); color: var(--text);
  font-family: var(--font); font-size: 13px;
  margin: 6px 0; outline: none; transition: border-color 0.2s;
}
.input-field:focus { border-color: var(--accent); }
.input-field::placeholder { color: var(--muted); }

.outline-btn {
  display: block; width: 100%; padding: 13px;
  background: transparent;
  border: 1px solid rgba(212,105,138,0.4);
  border-radius: var(--rs); color: var(--accent);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: center; margin-top: 6px; transition: all 0.15s;
}
.outline-btn:active { background: rgba(212,105,138,0.08); }

/* ══════════════════════════════════════════
   BOT LIST & CARDS
══════════════════════════════════════════ */
.bot-list { padding: 0 14px; display: flex; flex-direction: column; gap: 10px; }

.bot-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer; overflow: hidden;
  transition: transform 0.15s, border-color 0.2s;
}
.bot-item:active { transform: scale(0.985); border-color: var(--border-hi); }

/* Gradient banner strip */
.bot-item__banner {
  height: 5px; width: 100%;
}

.bot-item__inner {
  display: flex; gap: 14px;
  padding: 14px; align-items: flex-start;
}

.bot-item__icon {
  width: 66px; height: 66px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.bot-item__body { flex: 1; min-width: 0; }
.bot-item__name {
  font-size: 13px; font-weight: 700;
  margin-bottom: 4px; color: var(--text); line-height: 1.3;
}
.bot-item__desc {
  font-size: 12px; color: var(--text2);
  line-height: 1.45; margin-bottom: 10px;
}
.bot-item__btns { display: flex; gap: 6px; align-items: center; }

.bot-btn {
  padding: 8px 16px; border-radius: 50px;
  font-family: var(--font); font-size: 11px; font-weight: 700;
  cursor: pointer; border: none; transition: all 0.15s;
}
.bot-btn--fill {
  background: var(--grad); color: #fff;
  box-shadow: 0 3px 12px rgba(212,105,138,0.3);
}
.bot-btn--line {
  background: transparent;
  border: 1px solid rgba(212,105,138,0.45);
  color: var(--accent);
}
.bot-btn:active { transform: scale(0.93); }

/* ══════════════════════════════════════════
   FULL WIDTH BUTTON
══════════════════════════════════════════ */
.full-btn {
  display: block; width: calc(100% - 28px);
  margin: 14px auto; padding: 15px;
  background: var(--grad); border: none; border-radius: 50px;
  color: #fff; font-family: var(--font); font-size: 15px; font-weight: 700;
  cursor: pointer; text-align: center;
  box-shadow: 0 6px 22px rgba(155,92,232,0.3);
  transition: all 0.2s;
}
.full-btn:active { transform: scale(0.97); opacity: 0.85; }

/* ══════════════════════════════════════════
   SETTINGS
══════════════════════════════════════════ */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.setting-label { font-size: 14px; font-weight: 600; }
.setting-desc  { font-size: 12px; color: var(--dim); margin-top: 3px; line-height: 1.4; }

.lang-switch { display: flex; gap: 6px; flex-shrink: 0; }
.lang-btn {
  padding: 9px 18px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 50px; color: var(--dim);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.lang-btn.active {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 3px 14px rgba(212,105,138,0.35);
}

/* ══════════════════════════════════════════
   BOTTOM NAV
══════════════════════════════════════════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(8,8,8,0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 7px 4px;
  background: none; border: none; color: var(--dim);
  font-family: var(--font); cursor: pointer; transition: color 0.2s;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; transition: transform 0.2s; }
.nav-item.active .nav-icon { transform: scale(1.12); }
.nav-label { font-size: 9px; font-weight: 600; letter-spacing: 0.3px; }
.nav-item.active .nav-label {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ══════════════════════════════════════════
   OVERLAY PAGES
══════════════════════════════════════════ */
.overlay-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 200;
  overflow-y: auto; padding-bottom: 40px;
  animation: slideIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.overlay-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(8,8,8,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
}
.overlay-header__title { font-size: 12px; color: var(--dim); font-weight: 500; }
.back-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--accent); font-size: 14px; font-weight: 600;
  cursor: pointer; padding: 7px 14px;
  font-family: var(--font); border-radius: 50px;
  transition: opacity 0.15s;
}
.back-btn:active { opacity: 0.7; }

.page-title {
  font-size: 30px; font-weight: 800;
  padding: 16px 16px 12px; letter-spacing: -0.8px;
}

/* ══════════════════════════════════════════
   PACKAGES
══════════════════════════════════════════ */
.packages-list { padding: 0 14px; display: flex; flex-direction: column; gap: 12px; }

.pkg-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  cursor: pointer; transition: all 0.2s;
}
.pkg-card:active { border-color: var(--accent); transform: scale(0.99); }

.pkg-card__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 18px 16px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.pkg-card__name {
  font-size: 20px; font-weight: 900; font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.pkg-card__sp {
  font-size: 17px; font-weight: 800;
  font-family: var(--font-mono); color: var(--text);
}
.pkg-card__section {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--dim); padding: 12px 18px 6px;
}
.pkg-card__bonus { font-size: 13px; font-weight: 600; padding: 0 18px 4px; }
.pkg-card__desc  { font-size: 12px; color: var(--text2); padding: 0 18px 8px; line-height: 1.5; }
.pkg-card__row { display: flex; justify-content: space-between; padding: 3px 18px; font-size: 12px; }
.pkg-card__row span:first-child { color: var(--text2); }
.pkg-card__row span:last-child  { font-weight: 700; }
.pkg-card__more { font-size: 11px; color: var(--muted); padding: 2px 18px 10px; }
.pkg-card__btn {
  display: block; width: calc(100% - 32px);
  margin: 12px 16px 16px; padding: 13px;
  background: var(--grad); border: none; border-radius: 50px;
  color: #fff; font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(155,92,232,0.3);
  transition: all 0.15s;
}
.pkg-card__btn:active { transform: scale(0.97); opacity: 0.85; }

/* ══════════════════════════════════════════
   PACKAGE DETAIL
══════════════════════════════════════════ */
.notice-card {
  background: var(--grad); color: #fff;
  border-radius: var(--r); padding: 16px; margin: 12px 14px;
  box-shadow: 0 6px 22px rgba(155,92,232,0.28);
}
.notice-card h3 { font-size: 15px; font-weight: 800; margin-bottom: 5px; }
.notice-card p  { font-size: 12px; opacity: 0.9; }

.pkg-detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px; margin: 12px 14px;
}
.pkg-detail-card .d-name {
  font-size: 22px; font-weight: 900; font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 14px;
}
.pkg-detail-card .d-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.pkg-detail-card .d-row:last-of-type { border-bottom: none; }
.pkg-detail-card .d-row span:first-child { color: var(--text2); }
.pkg-detail-card .d-row span:last-child  { font-weight: 700; }
.pkg-detail-card .d-partner {
  font-size: 15px; font-weight: 800;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pkg-detail-card .d-sub { font-size: 12px; color: var(--dim); margin-top: 3px; }

.form-group { padding: 0 14px; margin-bottom: 10px; }
.form-label  { font-size: 12px; font-weight: 600; display: block; margin-bottom: 5px; color: var(--text2); }

.checkbox-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 0 14px; margin-bottom: 12px;
  font-size: 12px; color: var(--text2); cursor: pointer; line-height: 1.5;
}
.checkbox-row input { accent-color: var(--accent); margin-top: 2px; flex-shrink: 0; }

/* ══════════════════════════════════════════
   FAVORITE BUTTON
══════════════════════════════════════════ */
.fav-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--dim); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.2s; padding: 0;
}
.fav-btn--active {
  background: rgba(212,105,138,0.15);
  border-color: rgba(212,105,138,0.5);
  color: var(--accent);
}

/* ══════════════════════════════════════════
   BOT DETAIL PAGE
══════════════════════════════════════════ */
#bot-detail-hero { padding-bottom: 30px; }

.bd-hero-banner {
  width: 100%; height: 200px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.bd-hero-banner::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 90px;
  background: linear-gradient(transparent, var(--bg));
}
.bd-hero-emoji {
  font-size: 90px;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.6));
  position: relative; z-index: 1;
}

.bd-info-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 0 16px;
}
.bd-icon-small {
  width: 54px; height: 54px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  margin-top: -10px;
}
.bd-info-text { flex: 1; min-width: 0; }
.bd-name { font-size: 18px; font-weight: 800; margin-bottom: 5px; line-height: 1.3; }
.bd-desc { font-size: 13px; color: var(--text2); line-height: 1.5; }

.bd-btns { display: flex; gap: 8px; align-items: center; padding: 16px; }
.bd-divider { height: 1px; background: var(--border); margin: 0 16px 20px; }
.bd-section { padding: 0 16px; margin-bottom: 22px; }
.bd-section h3 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.bd-section p  { font-size: 13px; color: var(--text2); line-height: 1.7; }

/* ══════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════ */
.server-time { display: none; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); color: var(--text);
  padding: 11px 22px; border-radius: 50px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  z-index: 1000; border: 1px solid var(--border-hi);
  animation: fadeUp 0.25s ease; white-space: nowrap;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}

::-webkit-scrollbar { width: 2px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ══════════════════════════════════════════
   BOT CARD — CHAT BUTTON
══════════════════════════════════════════ */
.bot-btn--chat {
  background: var(--grad);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.18s;
}
.bot-btn--chat:active { opacity: 0.75; }

/* ══════════════════════════════════════════
   CHAT OVERLAY PAGE
══════════════════════════════════════════ */
.chat-page {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  /* Override overlay-page defaults */
  overflow-y: hidden;
  padding-bottom: 0;
}

/* ── Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 58px;
  position: relative;
  z-index: 10;
}
.chat-back-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-back-btn:active { background: var(--surface3); }

.chat-header__bot {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
  transition: background 0.15s;
}
.chat-header__bot:active { background: var(--surface3); }

.chat-header__icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-header__name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.chat-header__chevron {
  color: var(--text2);
  font-size: 18px;
  line-height: 1;
  transition: transform 0.2s;
}
.chat-header__bot.open .chat-header__chevron {
  transform: rotate(90deg);
}

.chat-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chat-sp-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--grad-glow);
  border: 1px solid rgba(212,105,138,0.25);
  border-radius: 50px;
  padding: 4px 10px;
}
.chat-sp-badge__coin {
  font-size: 13px;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}
.chat-sp-badge__val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.chat-new-btn {
  background: var(--grad);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.chat-new-btn:active { opacity: 0.7; }

/* ── Thread panel (slide-in from left) ── */
.thread-panel {
  position: absolute;
  top: 58px; left: 0;
  width: 75%;
  max-width: 300px;
  bottom: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.thread-panel.open {
  transform: translateX(0);
}
.thread-panel__head,
.thread-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.thread-panel__close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.thread-panel__close:hover { color: var(--text); background: var(--surface3); }

.thread-new-btn {
  margin: 8px 12px 12px;
  width: calc(100% - 24px);
  background: var(--grad);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.thread-new-btn:active { opacity: 0.75; }
.thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.thread-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 0;
}
.thread-item:active,
.thread-item:hover { background: var(--surface2); }
.thread-item.active { background: var(--grad-glow); }
.thread-item__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}
.thread-item.active .thread-item__dot {
  background: var(--grad);
  background: linear-gradient(135deg, #D4698A 0%, #9B5CE8 100%);
}
.thread-item__info { flex: 1; min-width: 0; }
.thread-item__title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.thread-item.active .thread-item__title {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.thread-item__date {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}
.thread-item__del {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.thread-item__del:hover { color: var(--accent); background: rgba(212,105,138,0.12); }

.thread-overlay {
  position: absolute;
  inset: 0;
  top: 58px;
  background: rgba(0,0,0,0.55);
  z-index: 40;
  display: none;
}
.thread-overlay.visible { display: block; }

/* ── Message area ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
}
.chat-empty__icon {
  font-size: 52px;
  opacity: 0.6;
}
.chat-empty__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.chat-empty__sub {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* ── SP empty banner ── */
.chat-sp-empty {
  margin: 0 14px 10px;
  padding: 14px 16px;
  background: rgba(212,105,138,0.1);
  border: 1px solid rgba(212,105,138,0.3);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}
.chat-sp-empty__icon { font-size: 22px; }
.chat-sp-empty__text { flex: 1; font-size: 13px; color: var(--text2); line-height: 1.5; }
.chat-sp-empty__text strong { color: var(--accent); }
.chat-sp-empty button,
.chat-sp-empty__btn {
  background: var(--grad);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  padding: 7px 14px;
  border-radius: 50px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Message bubbles ── */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg--user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.msg--full {
  max-width: 100%;
  width: 100%;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}
.msg--user .msg-bubble {
  background: var(--grad);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg--assistant .msg-bubble {
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border);
}

/* Markdown inside bubbles */
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble pre {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.msg-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble ul, .msg-bubble ol {
  padding-left: 18px;
  margin: 6px 0;
}
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; opacity: 0.9; }
.msg-bubble a { color: var(--accent); text-decoration: none; }
.msg--user .msg-bubble a { color: rgba(255,255,255,0.85); }
.msg-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 6px 0;
  opacity: 0.8;
}
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-weight: 700;
  margin: 8px 0 4px;
  font-size: 15px;
}

.msg-time {
  font-size: 10px;
  color: var(--dim);
  margin-top: 3px;
  padding: 0 4px;
}

/* Text content inside bubble */
.msg-text { line-height: 1.55; }

/* Image attachment in message — class is on <img> element */
.msg-image {
  display: block;
  border-radius: 12px;
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
  object-fit: cover;
  cursor: pointer;
  margin-bottom: 4px;
}

/* File attachment — class is on <a> element */
.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  max-width: 220px;
  transition: background 0.15s;
}
.msg-file:hover { background: var(--surface3); }
.msg--user .msg-file { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.25); color: #fff; }

/* Audio attachment — class is on <audio> element */
.msg-audio {
  display: block;
  width: 220px;
  max-width: 100%;
  border-radius: 10px;
}

/* Typing indicator — .msg-typing on outer div */
.msg-typing {
  min-width: 60px;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text2);
  display: inline-block;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* API stub message — .msg-stub on outer .msg div */
.msg-stub {
  max-width: 100%;
  align-self: stretch;
}
.msg-stub .msg-text,
.stub-text {
  background: var(--grad-glow);
  border: 1px solid rgba(155,92,232,0.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

/* ── Input area ── */
.chat-input-area {
  padding: 8px 12px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chat-attach-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px 6px;
  border-radius: 10px;
  line-height: 1;
  flex-shrink: 0;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
  align-self: flex-end;
  margin-bottom: 2px;
}
.chat-attach-btn:active,
.chat-attach-btn:hover { background: var(--surface3); color: var(--accent); }

.chat-input-wrap {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
}

.chat-attached-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 0;
}
.chat-attached-preview:empty { display: none; }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface3);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  max-width: 120px;
}
.attach-chip img {
  width: 24px; height: 24px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.attach-chip__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.attach-chip__rm {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.attach-chip__rm:hover { color: var(--accent); }

/* Simple button inside attach-chip (no explicit class) */
.attach-chip button {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.attach-chip button:hover { color: var(--accent); }

.chat-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 12px;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  display: block;
}
.chat-textarea::placeholder { color: var(--dim); }

.chat-send-btn {
  background: var(--grad);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 2px;
  transition: opacity 0.15s, transform 0.15s;
}
.chat-send-btn:active { opacity: 0.75; transform: scale(0.92); }
.chat-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

