:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #172033;
  --muted: #64748b;
  --border: #d8e0ea;
  --primary: #0f172a;
  --primary-text: #ffffff;
  --accent: #0f9f6e;
  --accent-2: #2563eb;
  --danger: #dc2626;
  --ring: #1d4ed8;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #121a2b;
    --surface-2: #192338;
    --text: #eef4ff;
    --muted: #9aa8bd;
    --border: #2f3c54;
    --primary: #e6edf9;
    --primary-text: #0b1020;
    --accent: #22c55e;
    --accent-2: #60a5fa;
    --danger: #f87171;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ring) 35%, transparent);
  outline-offset: 2px;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(460px, 100%);
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-block,
.brand-inline,
.account-pill,
.pane-title,
.chat-header,
.composer-actions,
.switch-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 800;
}

.brand-mark.compact {
  width: 34px;
  height: 34px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 15px;
}

.brand-block p,
.brand-inline span,
.chat-header p,
.demo-accounts span {
  color: var(--muted);
  font-size: 13px;
}

.login-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.login-form label,
.stack-form label {
  display: grid;
  gap: 6px;
}

.login-form span {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

button,
.file-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: var(--primary-text);
  padding: 0 14px;
  font-weight: 650;
  transition: background 180ms ease, transform 180ms ease, border-color 180ms ease;
}

button:hover,
.file-button:hover span {
  transform: translateY(-1px);
}

.ghost-button,
.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.alert {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: 6px;
  color: var(--danger);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.demo-accounts {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

code {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 6px 8px;
  color: var(--accent-2);
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: 58px 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 18px;
}

.brand-inline {
  gap: 10px;
}

.brand-inline > div:last-child {
  display: grid;
}

.account-pill {
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(380px, 1fr) minmax(280px, 340px);
  height: calc(100vh - 58px);
  min-height: 0;
  overflow: hidden;
}

.conversation-pane,
.chat-pane,
.action-pane {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.action-pane {
  border-right: 0;
  overflow: auto;
}

.pane-title,
.chat-header {
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}

.conversation-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 10px;
}

.conversation-form input {
  min-width: 0;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 6px;
  height: calc(100vh - 177px);
  overflow-y: auto;
  padding: 10px;
}

.conversation-item {
  position: relative;
  width: 100%;
  min-height: 64px;
  justify-content: flex-start;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 10px 42px 10px 10px;
}

.conversation-item.active {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, var(--surface));
}

.conversation-item strong,
.conversation-item .conversation-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item .conversation-meta {
  color: var(--muted);
  font-size: 12px;
}

.conversation-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 0 6px;
  box-shadow: 0 0 0 2px var(--surface);
}

.chat-pane {
  display: grid;
  grid-template-rows: 58px 1fr auto;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: color-mix(in srgb, var(--surface-2) 65%, var(--surface));
}

.message {
  width: min(76%, 720px);
  margin-bottom: 12px;
}

.message.own {
  margin-left: auto;
}

.message-bubble {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.message.own .message-bubble {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.card-message {
  display: grid;
  gap: 8px;
}

.card-message img,
.attachment-preview img,
.attachment-preview video {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 6px;
}

.card-message .price {
  color: var(--accent);
  font-weight: 750;
}

.attachment-link {
  color: var(--accent-2);
  font-weight: 650;
  text-decoration: none;
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px;
}

.emoji-tools {
  position: relative;
  margin-bottom: 8px;
}

.emoji-picker {
  position: absolute;
  left: 0;
  bottom: 42px;
  z-index: 10;
  width: min(420px, calc(100vw - 32px));
  height: 318px;
  display: grid;
  grid-template-rows: 50px 1fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-tabs {
  display: flex;
  gap: 4px;
  height: 50px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  padding: 8px;
}

.emoji-tabs::-webkit-scrollbar,
.emoji-grid::-webkit-scrollbar {
  display: none;
}

.emoji-tab {
  min-height: 30px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
}

.emoji-tab.active {
  border-color: var(--accent-2);
  color: var(--text);
  background: color-mix(in srgb, var(--accent-2) 10%, var(--surface));
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-auto-rows: 38px;
  align-content: start;
  gap: 4px;
  height: 268px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 8px;
}

.emoji-item {
  width: 100%;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}

.emoji-message {
  font-size: 26px;
  line-height: 1.3;
}

.composer-actions {
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tool-section {
  border-bottom: 1px solid var(--border);
  padding: 14px;
}

.tool-section h2 {
  margin-bottom: 10px;
}

.module-list {
  display: grid;
  gap: 8px;
}

.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.switch-row {
  justify-content: space-between;
}

.switch-row input {
  width: 44px;
  height: 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 240px 1fr;
  }

.action-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 10px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .conversation-pane,
  .chat-pane,
  .action-pane {
    border-right: 0;
  }

  .conversation-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 76vw);
    overflow-x: auto;
  }

  .chat-pane {
    height: 70vh;
    min-height: 70vh;
  }

  .message {
    width: 92%;
  }

  .action-pane {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


body.embedded {
  background: transparent;
}

body.embedded .topbar {
  display: none;
}

body.embedded .workspace {
  height: 100vh;
  min-height: 0;
}

body.embedded .action-pane {
  display: none;
}

body.embedded .conversation-form {
  display: none;
}

body.embedded .app-shell {
  min-height: 100vh;
}

body.conversation-only .conversation-pane {
  display: none;
}

body.conversation-only .chat-pane {
  min-width: 0;
}

body.embedded .workspace {
  grid-template-columns: minmax(220px, 280px) minmax(380px, 1fr);
}

body.embedded .chat-pane {
  height: 100vh;
}

body.conversation-only .workspace {
  grid-template-columns: minmax(0, 1fr);
}
