/* ============ TOKENS ============ */
:root {
  --bg: #1b1c1d;
  --bg-2: #1f2021;
  --side: #1b1c1d;
  --side-hover: #2a2b2d;
  --surface: #1e1f20;
  --surface-2: #282a2c;
  --line: #3c4043;
  --text: #e3e3e3;
  --text-dim: #9aa0a6;
  --text-soft: #c4c7c5;
  --accent: #8ab4f8;
  --accent-2: #c58af9;
  --grad: linear-gradient(90deg, #4f8cff 0%, #b061ff 50%, #ff6ec7 100%);
  --shadow: 0 8px 24px rgba(0,0,0,.4);
  --radius: 28px;
  --side-w: 260px;
  --side-w-collapsed: 72px;
}
body[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f8fafd;
  --side: #f0f4f9;
  --side-hover: #e1e7ef;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --line: #dadce0;
  --text: #1f1f1f;
  --text-dim: #5f6368;
  --text-soft: #444746;
  --shadow: 0 4px 18px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Google Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  overflow: hidden;
}
body.side-collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }
body.side-collapsed .sidebar .lbl,
body.side-collapsed .sidebar .side-recent,
body.side-collapsed .sidebar .side-section-title { display: none; }
body.side-collapsed .new-chat { justify-content: center; padding: 12px; }
body.side-collapsed .side-item { justify-content: center; padding: 12px; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
textarea { font: inherit; color: inherit; background: none; border: 0; outline: 0; resize: none; }

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--side);
  height: 100vh;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  border-right: 1px solid transparent;
}
.side-top { padding: 6px 8px 4px; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-soft);
  transition: background .15s;
}
.icon-btn:hover { background: var(--side-hover); }
.icon-btn svg { width: 22px; height: 22px; }

.new-chat {
  margin: 6px 6px 14px;
  height: 48px;
  border-radius: 999px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px 0 14px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  transition: background .15s, transform .1s;
}
.new-chat:hover { background: #34363a; }
body[data-theme="light"] .new-chat { background: #d3e3fd; color: #041e49; }
body[data-theme="light"] .new-chat:hover { background: #c2d7fc; }
.new-chat svg { width: 20px; height: 20px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.side-item {
  display: flex; align-items: center; gap: 14px;
  height: 44px;
  padding: 0 12px 0 14px;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 14px;
  transition: background .15s;
  text-align: left;
}
.side-item:hover { background: var(--side-hover); color: var(--text); }
.side-item.active { background: var(--side-hover); color: var(--text); }
.side-item svg { width: 20px; height: 20px; flex: 0 0 auto; }
.side-item .ico-grad { color: #c58af9; }

.side-recent {
  margin-top: 18px;
  padding: 0 6px;
  flex: 1;
  overflow-y: auto;
}
.side-section-title {
  font-size: 14px; color: var(--text-soft);
  padding: 6px 14px 8px;
}
.recent-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-soft);
  border-radius: 999px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s;
}
.recent-item:hover { background: var(--side-hover); color: var(--text); }

.side-bottom { padding: 4px; }

/* ============ MAIN ============ */
.main {
  display: flex; flex-direction: column;
  height: 100vh;
  min-width: 0;
  background: var(--bg);
  grid-column: 2;
}

/* topbar */
.topbar {
  height: 64px;
  display: flex; align-items: center;
  padding: 0 12px;
  gap: 8px;
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 5;
}
.mobile-only { display: none; }
.model-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text);
  font-size: 18px;
  transition: background .15s;
}
.model-pill:hover { background: var(--surface-2); }
.model-title { font-weight: 500; }
.model-sub { color: var(--text-dim); margin-left: 4px; }
.caret { width: 18px; height: 18px; color: var(--text-dim); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.upgrade-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: background .15s, transform .1s;
}
.upgrade-btn:hover { background: #34363a; }
.upgrade-btn svg { width: 18px; height: 18px; color: #c58af9; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f8cff, #b061ff);
  color: #fff; font-weight: 600;
  display: grid; place-items: center;
}

/* ============ VIEWS GENERAL ============ */
.view { display: none; flex-direction: column; flex: 1; min-height: 0; }
body[data-view="chat"]     .view[data-view="chat"],
body[data-view="bots"]     .view[data-view="bots"],
body[data-view="programs"] .view[data-view="programs"],
body[data-view="studio"]   .view[data-view="studio"],
body[data-view="shop"]     .view[data-view="shop"] { display: flex; }

/* ============ CHAT VIEW ============ */
.view-chat { position: relative; }
.chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 0 20px 16px;
  display: flex; flex-direction: column;
}
.welcome {
  max-width: 820px;
  margin: 14vh auto 0;
  text-align: left;
  width: 100%;
}
.hello { font-size: 56px; font-weight: 500; line-height: 1.1; margin: 0; letter-spacing: -.02em; }
.hello .grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hello-sub { font-size: 32px; color: var(--text-dim); margin: 6px 0 36px; font-weight: 400; }

.suggestions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.sugg {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 16px;
  min-height: 130px;
  text-align: left;
  color: var(--text);
  display: flex; flex-direction: column; justify-content: space-between;
  gap: 12px;
  transition: background .15s, transform .1s;
  font-size: 14px; line-height: 1.4;
}
body[data-theme="light"] .sugg { background: var(--surface-2); }
.sugg:hover { background: var(--surface-2); }
.sugg svg { width: 22px; height: 22px; color: var(--accent); align-self: flex-end; }

/* messages */
.messages {
  max-width: 820px;
  width: 100%;
  margin: 24px auto 0;
  display: flex; flex-direction: column;
  gap: 24px;
}
.msg {
  display: flex; gap: 14px;
  animation: fadeUp .25s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-weight: 600;
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, #4f8cff, #b061ff);
  color: #fff;
}
.msg.bot .msg-avatar {
  background: var(--surface-2);
}
.msg.bot .msg-avatar svg { width: 20px; height: 20px; }
.msg-body { padding-top: 4px; font-size: 16px; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.msg-body.typing { color: var(--text-dim); }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* composer */
.composer-wrap {
  padding: 8px 20px 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
.composer {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 12px 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  box-shadow: var(--shadow);
}
body[data-theme="light"] .composer { background: var(--surface-2); box-shadow: none; border: 1px solid var(--line); }
.composer textarea {
  min-height: 28px; max-height: 180px;
  padding: 8px 4px;
  font-size: 16px;
  width: 100%;
}
.composer textarea::placeholder { color: var(--text-dim); }
.composer-actions { display: flex; gap: 4px; align-items: center; }
.composer-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-soft);
  transition: background .15s;
}
.composer-icon:hover { background: var(--surface-2); }
body[data-theme="light"] .composer-icon:hover { background: #e1e7ef; }
.composer-icon svg { width: 22px; height: 22px; }
.send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff;
  transition: opacity .15s, transform .1s;
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled { opacity: .4; cursor: default; transform: none; }
.composer-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin: 10px 0 0;
}

/* ============ STORE (BOTS / PROGRAMS) ============ */
.view-store { overflow-y: auto; }
.store-head {
  max-width: 1100px; width: 100%;
  margin: 12px auto 0;
  padding: 24px 28px 0;
}
.store-head h1 { font-size: 40px; margin: 0 0 8px; font-weight: 500; letter-spacing: -.01em; }
.store-head > p { color: var(--text-dim); font-size: 16px; margin: 0 0 18px; max-width: 720px; }
.store-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tab {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.tab:hover { background: #34363a; color: var(--text); }
body[data-theme="light"] .tab:hover { background: #d3e3fd; color: #041e49; }
.tab.active { background: var(--text); color: var(--bg); }

.cards {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: background .15s, transform .12s;
}
.card:hover { background: var(--surface-2); transform: translateY(-2px); }
.card-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff; font-size: 28px;
}
.card-title { font-size: 18px; font-weight: 500; margin: 0; }
.card-tagline { font-size: 13px; color: var(--text-dim); margin: 0; flex: 1; line-height: 1.45; }
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.card-price {
  font-size: 14px; font-weight: 500;
  color: var(--text);
}
.card-price.free { color: #5bb974; }
.card-price.premium { color: #c58af9; }
.btn-pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}
body[data-theme="light"] .btn-pill { background: #d3e3fd; color: #041e49; }
.btn-pill:hover { background: #3c4043; }
body[data-theme="light"] .btn-pill:hover { background: #c2d7fc; }
.btn-pill.cta { background: var(--grad); color: #fff; }

/* ============ STUDIO VIEW ============ */
.view-studio { overflow-y: auto; }
.studio-banner {
  height: 200px;
  background:
    radial-gradient(circle at 20% 30%, rgba(176,97,255,.55), transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(255,110,199,.45), transparent 50%),
    linear-gradient(135deg, #1a1f3c, #3c1f4e);
}
.studio-header {
  max-width: 1100px;
  margin: -54px auto 0;
  padding: 0 28px;
  display: flex; gap: 22px;
  position: relative;
}
.studio-avatar {
  width: 128px; height: 128px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff; font-size: 64px; font-weight: 600;
  display: grid; place-items: center;
  border: 4px solid var(--bg);
  flex: 0 0 auto;
}
.studio-info { padding-top: 60px; min-width: 0; }
.studio-info h1 { font-size: 32px; margin: 0; font-weight: 600; }
.studio-meta { color: var(--text-dim); font-size: 14px; margin: 4px 0 8px; }
.studio-info p { color: var(--text-soft); font-size: 14px; margin: 0 0 12px; max-width: 720px; }
.studio-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-primary {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  font-size: 14px;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-ghost {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  transition: background .15s;
}
.btn-ghost:hover { background: #34363a; }

.studio-tabs {
  max-width: 1100px;
  margin: 28px auto 0;
  padding: 0 28px;
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
}
.studio-tabs .tab {
  border-radius: 0;
  background: transparent;
  padding: 14px 16px;
  border-bottom: 3px solid transparent;
  color: var(--text-dim);
}
.studio-tabs .tab:hover { background: transparent; color: var(--text); }
.studio-tabs .tab.active {
  background: transparent;
  color: var(--text);
  border-bottom-color: var(--text);
}

.studio-catalog {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  display: flex; flex-direction: column;
  gap: 36px;
}
.playlist-row h2 {
  font-size: 20px; font-weight: 500; margin: 0 0 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.playlist-row h2 .more {
  font-size: 13px; color: var(--text-dim); font-weight: 400;
  cursor: pointer;
}
.playlist-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.video-card {
  display: flex; flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform .12s;
}
.video-card:hover { transform: translateY(-2px); }
.video-thumb {
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 600;
  text-align: center;
  padding: 14px;
  line-height: 1.25;
}
.video-thumb .duration {
  position: absolute; right: 6px; bottom: 6px;
  font-size: 11px;
  background: rgba(0,0,0,.75);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.video-thumb .ep {
  position: absolute; left: 6px; top: 6px;
  font-size: 11px;
  background: rgba(0,0,0,.6);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.video-card .video-title { font-size: 14px; font-weight: 500; line-height: 1.35; }
.video-card .video-meta { font-size: 12px; color: var(--text-dim); }

/* ============ SHOP VIEW ============ */
.view-shop { overflow-y: auto; }
.shop-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 28px 12px;
}
.shop-hero h1 { font-size: 40px; margin: 0 0 8px; font-weight: 500; letter-spacing: -.01em; }
.shop-hero p { color: var(--text-dim); font-size: 16px; margin: 0; max-width: 720px; }
.shop-tabs {
  max-width: 1100px;
  margin: 18px auto 0;
  padding: 0 28px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.shop-cards .card { padding: 0; overflow: hidden; }
.shop-thumb {
  aspect-ratio: 1 / 1;
  display: grid; place-items: center;
  font-size: 64px;
  color: #fff;
  font-weight: 600;
  text-align: center;
}
.shop-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.shop-body .card-title { font-size: 16px; }
.shop-body .card-tagline { font-size: 12px; }

/* ============ POPUP ============ */
[hidden] { display: none !important; }
.popup-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: grid; place-items: center;
  z-index: 50;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.popup {
  background: var(--surface);
  border-radius: 28px;
  padding: 32px 28px 24px;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: 0 24px 48px rgba(0,0,0,.55);
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.popup-emblem { width: 72px; height: 72px; margin: 0 auto 14px; }
.popup-emblem svg { width: 100%; height: 100%; }
.popup h2 { font-size: 22px; font-weight: 500; margin: 0 0 10px; line-height: 1.25; }
.popup p { color: var(--text-dim); margin: 0 0 22px; }
.popup .btn-primary { width: 100%; padding: 12px; font-size: 15px; }

.side-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 20;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  body { grid-template-columns: 0 1fr; }
  body.side-open { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .25s;
    box-shadow: var(--shadow);
  }
  body.side-open .sidebar { transform: translateX(0); }
  body.side-collapsed .sidebar .lbl,
  body.side-collapsed .sidebar .side-recent,
  body.side-collapsed .sidebar .side-section-title { display: revert; }
  body.side-collapsed { grid-template-columns: 0 1fr; }
  .mobile-only { display: grid; }
  .upgrade-btn span { display: none; }
  .upgrade-btn { padding: 8px; }

  .hello { font-size: 40px; }
  .hello-sub { font-size: 22px; margin-bottom: 28px; }
  .welcome { margin-top: 8vh; }
  .suggestions { grid-template-columns: 1fr 1fr; }

  .store-head { padding: 16px 16px 0; }
  .store-head h1, .shop-hero h1 { font-size: 28px; }
  .cards { padding: 16px; }

  .studio-banner { height: 130px; }
  .studio-header { margin-top: -42px; padding: 0 16px; gap: 14px; flex-direction: column; }
  .studio-avatar { width: 88px; height: 88px; font-size: 44px; border-width: 3px; }
  .studio-info { padding-top: 4px; }
  .studio-info h1 { font-size: 24px; }
  .studio-tabs { padding: 0 16px; overflow-x: auto; }
  .studio-catalog { padding: 16px; }

  .shop-hero { padding: 20px 16px 8px; }
  .shop-tabs { padding: 0 16px; }

  .composer-wrap { padding: 8px 12px 12px; }
  .composer { padding: 8px 8px 8px 12px; border-radius: 22px; }
  .composer textarea { font-size: 15px; }
  .chat-scroll { padding: 0 12px 8px; }
}

@media (max-width: 520px) {
  .suggestions { grid-template-columns: 1fr; }
  .sugg { min-height: 96px; }
  .topbar { height: 56px; }
  .model-pill { font-size: 16px; padding: 6px 10px; }
}
