@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #0b141f;
  --panel: #0e1926;
  --raised: #162230;
  --field: #1a2838;
  --border: #243446;
  --text: #e3eaf3;
  --muted: #91a2b8;
  --blue: #1975f5;
  --green: #23d2a0;
  --purple: #a26aff;
  --shadow: 0 20px 80px #0008;
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }

body.light {
  color-scheme: light;
  --bg: #f6f8fc;
  --panel: #fff;
  --raised: #edf2f8;
  --field: #e8eef6;
  --border: #d3dce7;
  --text: #17283d;
  --muted: #546980;
  --green: #087d60;
  --purple: #7846cb;
}

button, input, select, textarea { font: inherit; }

button {
  cursor: pointer;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 11px;
  transition: background .15s;
}

button:hover { background: var(--field); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid #77b3ff;
  outline-offset: 3px;
}

input, textarea, select {
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px;
  min-width: 0;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  font-weight: 600;
}
button.primary:hover { background: #3589ff; }

small { font-size: 11px; color: var(--muted); }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 14px; }
h3 { font-size: 12px; }

i, .live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 32px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 225px;
}
.brand strong { font-size: 21px; display: block; letter-spacing: -.6px; }
.brand small { color: #a8b9eb; }
.brain { font-size: 45px; line-height: 1; color: #8865ff; }

.search {
  max-width: 620px;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding-left: 12px;
  color: var(--muted);
}
.search span { font-size: 24px; }
.search input { width: 100%; border: 0; background: transparent; padding: 12px; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon { font-size: 20px; border: 0; border-radius: 50%; background: var(--raised); padding: 5px 9px; }

.profile { display: flex; align-items: center; gap: 10px; border: 0; text-align: left; padding: 0; }
.profile small { display: block; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(140deg, #235c6c, #60958b);
  border: 2px solid #ffffff15;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.avatar.c1 { background: linear-gradient(140deg, #aa635b, #58477e); }
.avatar.c2 { background: linear-gradient(140deg, #325ab8, #379ecd); }
.avatar.c3 { background: linear-gradient(140deg, #9c4682, #595cb5); }
.avatar.c4 { background: linear-gradient(140deg, #b58840, #5d8261); }
.avatar.me { background: linear-gradient(140deg, #285185, #517b83); }

.workspace {
  display: grid;
  grid-template-columns: 245px minmax(320px, 1fr) 290px;
  height: calc(100dvh - 72px);
  min-height: 620px;
}

.sidebar {
  padding: 16px 10px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.sidebar h2 { padding: 0 5px 14px; }

.room-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  text-align: left;
  padding: 10px 8px;
  margin-bottom: 3px;
}
.room-btn.active {
  background: linear-gradient(90deg, #0753b7, #104484);
  color: white;
}
.room-btn small { display: block; margin-top: 3px; }
.room-btn.active small { color: #b0d4fa; }

.room-icon {
  font-size: 20px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #2489ff26;
  color: #79b6ff;
  flex-shrink: 0;
}
.room-btn:nth-child(2) .room-icon { background: #1f8a4233; color: #6ed391; }
.room-btn:nth-child(3) .room-icon { background: #782fce44; color: #ba8eff; }
.room-btn:nth-child(4) .room-icon { background: #8c40ab44; color: #d3a3f1; }
.room-btn:nth-child(5) .room-icon { background: #b87b1744; color: #f1c364; }
.room-btn:nth-child(6) .room-icon { background: #0ba5ac33; color: #5fdde0; }

.full { width: 100%; }
.subtle { background: var(--raised); margin: 8px 0; }

.people-head {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin: 12px 4px;
}
.people-head span { color: var(--muted); }

.person { display: flex; align-items: center; gap: 8px; padding: 5px; }
.person .avatar { width: 24px; height: 24px; font-size: 10px; }

.mini-ai {
  font-size: 10px;
  background: #8e42db;
  color: white;
  border-radius: 4px;
  padding: 2px 4px;
  overflow-wrap: anywhere;
}

.sidebar-bottom { font-size: 10px; color: var(--muted); margin-top: auto; padding: 22px 4px 0; line-height: 1.6; }

.chat { min-width: 0; display: flex; flex-direction: column; }
.channel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.channel-symbol { font-size: 29px; color: #aac1da; }
.channel-title { min-width: 0; flex: 1; }
h1 { font-size: 14px; margin-bottom: 6px; }
.channel-title p { font-size: 10px; color: var(--muted); display: flex; gap: 7px; align-items: center; }
.divider { padding: 0 4px; }
.channel-actions { display: flex; gap: 6px; }
.channel-actions button { font-size: 11px; padding: 7px 8px; white-space: nowrap; }

.messages { overflow: auto; padding: 4px 20px 16px; flex: 1; scroll-behavior: smooth; }
.msg { display: flex; gap: 12px; padding-top: 20px; }
.msg-body { min-width: 0; flex: 1; }
.msg-meta { display: flex; gap: 9px; align-items: center; margin-bottom: 5px; font-size: 12px; }
.msg-meta time { font-size: 10px; color: var(--muted); }
.msg p { line-height: 1.65; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .reply-action { font-size: 10px; padding: 3px 0; color: var(--muted); border: 0; opacity: .65; }
.msg:hover .reply-action, .reply-action:focus-visible { opacity: 1; color: #74b7ff; }

.ai-bubble {
  padding: 12px 14px;
  border: 1px solid #285383;
  border-radius: 10px;
  background: linear-gradient(120deg, #14304c66, #19263888);
}
body.light .ai-bubble { background: #eaf3ff; }
.ai-caption { font-size: 10px; color: #5cb9f8; margin-bottom: 6px; }

.composer { border-top: 1px solid var(--border); background: var(--panel); padding: 12px 16px; }
.reply-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.reply-line > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-line button { padding: 0 5px; border: 0; font-size: 20px; }

.compose-options { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 10px; margin: 8px 0; }
.mode { font-size: 11px; padding: 5px 14px; background: var(--raised); }
.mode.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.compose-options label { margin-left: auto; }
.compose-options select { font-size: 10px; padding: 5px; max-width: 180px; }

.composer textarea {
  width: 100%;
  resize: vertical;
  height: 68px;
  min-height: 60px;
  max-height: 180px;
  padding: 12px;
  background: var(--field);
  font-size: 12px;
}

.compose-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; gap: 12px; }
.compose-bottom > div { display: flex; align-items: center; gap: 14px; }
.compose-bottom span { font-size: 10px; color: var(--muted); }

.ai-panel {
  border-left: 1px solid var(--border);
  padding: 14px 12px;
  overflow: auto;
  background: var(--panel);
}
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.panel-title span { border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px; }

.panel-card {
  padding: 12px;
  background: var(--raised);
  border: 1px solid #ffffff03;
  border-radius: 9px;
  margin-bottom: 9px;
}
.panel-card h3 { margin-bottom: 9px; }
.panel-card h3 > span { color: var(--muted); margin-left: 5px; }
.panel-card > label:not(.radio) { display: block; font-size: 10px; margin: 8px 0 5px; }
.panel-card > input, .panel-card > select { width: 100%; font-size: 11px; padding: 7px; background: var(--panel); }
.panel-card > small { display: block; line-height: 1.6; margin-top: 6px; }

.connection {
  font-size: 10px;
  color: var(--green);
  background: #0c8b6420;
  border-radius: 5px;
  padding: 8px;
  margin-top: 7px;
}

.radio { display: flex; gap: 7px; align-items: flex-start; font-size: 11px; margin-top: 11px; cursor: pointer; }
.radio input { accent-color: var(--blue); margin: 3px 0 0; }
.radio small { display: block; font-size: 9px; line-height: 1.5; margin-top: 2px; }
.info { font-size: 10px; line-height: 1.6; background: #1265be25; color: #77b8fc; padding: 9px; border-radius: 5px; margin-top: 10px; }

.panel-card label.limit { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.limit select, .limit input { width: 72px; padding: 5px; font-size: 10px; }

.consumption { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.consumption > div { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 10px; }
.consumption strong { color: var(--green); font-size: 10px; }
.consumption progress {
  width: 100%;
  height: 5px;
  border: 0;
  accent-color: var(--green);
  margin: 13px 0 4px;
  display: block;
}
.consumption progress::-webkit-progress-bar { background: var(--border); border-radius: 5px; }
.consumption progress::-webkit-progress-value { background: var(--green); border-radius: 5px; }
.text-button { border: 0; color: #6bb6ff; font-size: 10px; display: block; margin-left: auto; padding: 10px 0 0; }
.demo-label { font-size: 8px; letter-spacing: .5px; }

.tip { display: flex; gap: 10px; padding: 12px; background: #6e33b124; border: 1px solid #7541ae; border-radius: 9px; }
.tip > span { font-size: 23px; color: #e4ba62; }
.tip h3 { color: #d8b9ff; }
.tip p { font-size: 10px; line-height: 1.6; color: var(--muted); margin-top: 5px; }
.demo-foot { font-size: 9px; text-align: center; color: var(--muted); margin: 12px 0; }

.notice { padding: 12px 18px; background: var(--raised); color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); }
#empty { padding: 24px; text-align: center; color: var(--muted); }

dialog {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: min(570px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: #020812b8; backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.dialog-head small { color: #aa8cff; letter-spacing: 1px; font-size: 9px; }
.dialog-head h2 { font-size: 20px; margin-top: 5px; }
.dialog-head button { border: 0; font-size: 23px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
dialog label { display: block; font-size: 12px; margin: 18px 0 8px; }
dialog textarea { width: 100%; min-height: 190px; line-height: 1.7; resize: vertical; }
dialog input { width: 100%; }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--field);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-width: 90vw;
  font-size: 12px;
}

.mobile-tabs { display: none; }
[hidden] { display: none !important; }

/* Credits & Wallet Styling */
.buy-credits {
  font-size: 10px;
  padding: 7px 8px;
  color: #8fc2ff;
  border-color: #2a527e;
  background: #1975f515;
  white-space: nowrap;
}

.credit-tabs {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 14px;
}
.credit-tabs button { border: 0; font-size: 11px; padding: 9px 5px; color: var(--muted); }
.credit-tabs button[aria-selected=true] {
  background: var(--field);
  color: var(--text);
  box-shadow: 0 2px 5px #0002;
}

.wallet-card {
  padding: 18px 15px;
  border: 1px solid #38619a;
  border-radius: 12px;
  background: linear-gradient(135deg, #1975f520, #7455da18), var(--raised);
  margin-bottom: 12px;
}
.wallet-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
}
.preview-tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 6px;
  color: var(--muted);
  background: var(--panel);
}

.wallet-balance {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -1px;
  margin: 14px 0 5px;
}
.wallet-balance span {
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 400;
}

.wallet-card p { font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.wallet-card .full { display: flex; justify-content: space-between; font-size: 12px; padding: 11px; }
.wallet-card > small { display: block; margin-top: 10px; font-size: 10px; line-height: 1.6; }

.credit-service { display: flex; gap: 10px; }
.service-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: #6e4ce52b;
  color: #b59bff;
  border-radius: 8px;
  font-size: 21px;
}
.credit-service p { font-size: 11px; line-height: 1.6; color: var(--muted); margin-bottom: 8px; }

.credit-explainer ol {
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
  display: grid;
  gap: 16px;
}
.credit-explainer li { display: flex; align-items: flex-start; gap: 10px; }
.credit-explainer li > span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  background: var(--field);
  color: var(--muted);
  border-radius: 50%;
  font-size: 10px;
}
.credit-explainer strong { font-weight: 500; font-size: 11px; }
.credit-explainer small { display: block; font-size: 10px; line-height: 1.6; margin-top: 4px; }

#credits-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 26px;
}
#credits-dialog .dialog-head { margin-bottom: 10px; }
#credits-dialog h2 { font-size: 22px; letter-spacing: -.5px; }
.credits-intro { color: var(--muted); font-size: 13px; line-height: 1.6; }

.credit-packages {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 14px;
}
.credit-package {
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 13px;
  padding: 18px 14px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 0;
}
.credit-package[aria-pressed=true] {
  border-color: #579fff;
  background: linear-gradient(145deg, #1975f526, #1975f507), var(--raised);
  box-shadow: 0 0 0 1px #579fff;
}
.credit-package > span:first-child { font-size: 11px; color: var(--muted); }
.credit-package strong { font-size: 25px; letter-spacing: -.8px; font-weight: 600; white-space: nowrap; }
.credit-package strong span { font-size: 16px; }
.credit-package b { font-size: 13px; font-weight: 500; }
.credit-package small { font-size: 10px; line-height: 1.5; }

.package-check { position: absolute; right: 10px; top: 12px; color: #88bfff; opacity: 0; }
.credit-package[aria-pressed=true] .package-check { opacity: 1; }

.credit-disclosure { font-size: 11px; color: var(--muted); line-height: 1.7; }
.credit-checkout {
  padding: 16px 0;
  margin-top: 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 12px;
}
.credit-checkout > div { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.credit-checkout span { color: var(--muted); }
.credit-checkout strong { font-weight: 500; }
.credit-checkout small { font-size: 10px; }

.ai-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.ai-buttons button { font-size: 11px; }

#ai-confirm p { margin: 14px 0; font-size: 12px; color: var(--muted); }
#ai-context-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow: auto;
  font: inherit;
  font-size: 12px;
}
#ai-confirm details { background: var(--raised); padding: 12px; border-radius: 8px; }

/* Responsividade */
@media (max-width: 950px) {
  .workspace { grid-template-columns: 180px minmax(0, 1fr); }
  .ai-panel { display: none; }
  .workspace.show-ai { grid-template-columns: minmax(0, 1fr) 260px; }
  .workspace.show-ai .sidebar { display: none; }
  .workspace.show-ai .ai-panel { display: block; }
  .topbar { padding: 0 14px; }
  .profile > span:not(.avatar) { display: none; }
  .brand { min-width: 165px; }
}

@media (max-width: 620px) {
  .topbar { height: 62px; gap: 12px; }
  .brand strong { font-size: 18px; }
  .brand small { display: none; }
  .brain { font-size: 32px; }
  .mobile-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
  }
  .mobile-tabs button { font-size: 11px; padding: 6px 9px; }
  .workspace { height: calc(100dvh - 108px); min-height: 500px; display: flex; }
  .sidebar { display: none; }
  .chat { width: 100%; }
  .workspace.show-rooms .sidebar { display: flex; width: 100%; }
  .workspace.show-rooms .chat, .workspace.show-rooms .ai-panel { display: none; }
  .workspace.show-ai .ai-panel { display: block; width: 100%; }
  .workspace.show-ai .chat { display: none; }
  .workspace.show-ai { display: flex; }
  .channel-header { padding: 12px; }
  .channel-symbol { display: none; }
  .credit-packages { grid-template-columns: 1fr; gap: 9px; margin-top: 18px; }
  .credit-package {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    padding: 12px 28px 12px 14px;
  }
  .credit-package strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 23px;
  }
}