/* VELA AI Office — стиль вдохновлён интерфейсом maxtreysi */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e6e8ec;
  --text: #1a1d24;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 90px;
}

.header {
  padding: 20px 16px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-back {
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 8px;
  display: inline-block;
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
}

.header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.section {
  padding: 16px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

/* ---------- Status banner ---------- */
.status-banner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.status-banner .title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 2px;
}
.status-banner .desc {
  font-size: 13px;
  opacity: 0.9;
}

/* ---------- Team grid (agents on home) ---------- */
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.team-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.team-card:active {
  transform: scale(0.97);
}
.team-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-light);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 8px;
  position: relative;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.team-avatar.status-online::after {
  content: "";
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid white;
}
.team-card .name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.team-card .role {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}
.team-card .title {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Goal box (главное поле — цель команде) ---------- */
.goal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.goal-box .head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.goal-box .head .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #4f46e5;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.goal-box .head .meta { flex: 1; }
.goal-box .head .name { font-weight: 600; font-size: 14px; }
.goal-box .head .role { font-size: 11px; color: var(--text-muted); }
.goal-box textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  background: var(--bg);
}
.goal-box textarea:focus { outline: none; border-color: var(--primary); }
.goal-box .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}
.goal-box .quick-goals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.goal-box .quick-goal {
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
}
.goal-result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: none;
}
.goal-result.show { display: block; }
.goal-result h3 { font-size: 14px; margin-bottom: 6px; }
.goal-result .plan {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.goal-result .delegations {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.goal-result .delegation-badge {
  font-size: 12px;
  background: var(--success-light);
  color: var(--success);
  padding: 4px 10px;
  border-radius: 12px;
}
.goal-result .final {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
}

/* ---------- Chat (общий чат AI Office) ---------- */
.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
}
.chat-msg .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--primary-light);
}
.chat-msg .content { flex: 1; min-width: 0; }
.chat-msg .head { display: flex; gap: 6px; align-items: baseline; margin-bottom: 4px; }
.chat-msg .name { font-weight: 600; font-size: 13px; }
.chat-msg .time { font-size: 11px; color: var(--text-muted); }
.chat-msg .title { font-size: 13px; margin-bottom: 4px; color: var(--text); }
.chat-msg .body { font-size: 12px; color: var(--text-muted); white-space: pre-wrap; line-height: 1.5; max-height: 80px; overflow: hidden; position: relative; }
.chat-msg .body.expanded { max-height: none; }
.chat-msg .show-more { font-size: 11px; color: var(--primary); cursor: pointer; margin-top: 4px; display: inline-block; }
.chat-msg.kind-alert { border-left: 3px solid var(--danger); }
.chat-msg.kind-standup { border-left: 3px solid var(--primary); }
.chat-msg.kind-report { border-left: 3px solid var(--success); }
.chat-msg.kind-handoff { border-left: 3px solid var(--warning); }

/* ---------- Brain VELA ---------- */
.brain-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.brain-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.brain-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.brain-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.brain-card .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.brain-card .title { font-weight: 600; font-size: 14px; }
.brain-card .status { font-size: 11px; padding: 2px 8px; border-radius: 12px; }
.brain-card .status-open { background: #dbeafe; color: #1d4ed8; }
.brain-card .status-success { background: var(--success-light); color: var(--success); }
.brain-card .status-fail { background: #fee2e2; color: var(--danger); }
.brain-card .row {
  display: flex;
  font-size: 12px;
  padding: 3px 0;
}
.brain-card .row .label { color: var(--text-muted); width: 110px; flex-shrink: 0; }
.brain-card .row .val { color: var(--text); }
.brain-card .author {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---------- Server stats ---------- */
.server-stats {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow);
}
.server-stats .icon {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.server-stats .values {
  display: flex;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.server-stats .val strong {
  font-weight: 600;
}
.server-stats .val span {
  color: var(--text-muted);
  margin-left: 2px;
}

/* ---------- Quick access (templates / actions) ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-decoration: none;
  color: inherit;
  text-align: center;
  box-shadow: var(--shadow);
}
.quick-tile .icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.quick-tile.tasks .icon { background: #dbeafe; color: #2563eb; }
.quick-tile.activity .icon { background: #ede9fe; color: #7c3aed; }
.quick-tile.new .icon { background: #d1fae5; color: #059669; }
.quick-tile .label {
  font-size: 12px;
  font-weight: 500;
}

/* ---------- Activity list ---------- */
.activity-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.activity-item {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-item .status-icon {
  width: 28px;
  height: 28px;
  background: var(--success-light);
  color: var(--success);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.activity-item .content {
  flex: 1;
  min-width: 0;
}
.activity-item .title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-item .meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 0 18px;
  z-index: 20;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0;
}
.nav-item.active {
  color: var(--primary);
}
.nav-item .icon {
  font-size: 20px;
}

/* ---------- Agent page ---------- */
.agent-hero {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.agent-hero .avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}
.agent-hero .name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}
.agent-hero .role {
  font-size: 13px;
  color: var(--text-muted);
}
.agent-hero .metric {
  margin-top: 10px;
  font-size: 12px;
  background: var(--success-light);
  color: var(--success);
  display: inline-block;
  padding: 5px 12px;
  border-radius: 16px;
}

.template-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.template-item {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.template-item:last-child { border-bottom: none; }
.template-item:active { background: var(--primary-light); }
.template-item .title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
}
.template-item .preview {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.task-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  background: var(--bg);
}
.task-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}
.btn:active { opacity: 0.85; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
  white-space: pre-wrap;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
}

.mock-badge {
  background: var(--warning);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 6px;
}

/* ---------- WB-box (главная) ---------- */
.wb-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.wb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.wb-title {
  font-weight: 700;
  font-size: 15px;
}
.wb-status {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
}
.wb-status.ok { background: #dcfce7; color: #166534; }
.wb-status.fail { background: #fee2e2; color: #991b1b; }
.wb-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.btn-secondary {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
}
.btn-secondary:hover { background: #e2e8f0; }
.uploads-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}
.upload-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-meta { color: #64748b; font-size: 11px; margin: 0 8px; }
.btn-link {
  background: transparent;
  border: none;
  color: #dc2626;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

/* ---------- VELA KPI tiles (заменяет server-stats) ---------- */
#vela-kpi .values { gap: 10px; flex-wrap: wrap; }
#vela-kpi .val { min-width: 70px; }

/* ---------- Knowledge Inbox ---------- */
.inbox-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 8px;
}
.inbox-box textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.inbox-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  background: #fafbfd;
}
.inbox-row.processed { background: #f0fdf4; border-color: #bbf7d0; }
.inbox-row.pending { background: #fffbeb; border-color: #fde68a; }
.inbox-head { font-weight: 500; margin-bottom: 4px; }
.inbox-tag {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}
.inbox-summary { color: #475569; font-size: 12px; margin: 4px 0; }
.inbox-meta { color: #94a3b8; font-size: 11px; }
.pill {
  display: inline-block;
  background: #4f46e5;
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  min-width: 16px;
  text-align: center;
}

/* ---------- Flags для status-banner ---------- */
.flag-red, .flag-yellow, .flag-blue, .flag-green {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 4px;
}
.flag-red { background: #fee2e2; color: #991b1b; }
.flag-yellow { background: #fef3c7; color: #92400e; }
.flag-blue { background: #dbeafe; color: #1e40af; }
.flag-green { background: #d1fae5; color: #065f46; }

/* ---------- Дайджест Макса (главный блок сверху) ---------- */
.digest-card {
  background: linear-gradient(135deg, #4f46e5 0%, #6d28d9 100%);
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}
.digest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.digest-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.digest-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.18); font-size: 15px;
}
.digest-date { font-size: 12px; opacity: 0.8; }
.digest-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.dkpi {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.dkpi-val { font-size: 17px; font-weight: 700; line-height: 1.2; }
.dkpi-val.drr-ok { color: #6ee7b7; }
.dkpi-val.drr-warn { color: #fcd34d; }
.dkpi-val.drr-bad { color: #fca5a5; }
.dkpi-label { font-size: 10px; opacity: 0.85; margin-top: 2px; }
.digest-summary {
  font-size: 13px;
  line-height: 1.55;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.digest-summary .flag-red, .digest-summary .flag-yellow,
.digest-summary .flag-blue, .digest-summary .flag-green {
  background: transparent; color: #fff; padding: 0; margin: 0;
}
.digest-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  opacity: 0.95;
}

/* ---------- Ждут твоего решения ---------- */
.decisions-list { display: flex; flex-direction: column; gap: 10px; }
.decision-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: opacity 0.2s;
}
.decision-head { font-size: 14px; margin-bottom: 4px; }
.decision-action { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.decision-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.decision-btns { display: flex; gap: 8px; }
.decision-btns button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-yes { background: var(--success-light); color: #065f46; }
.btn-no { background: #f3f4f6; color: var(--text-muted); }
.btn-yes:active { background: var(--success); color: #fff; }
.btn-no:active { background: #e5e7eb; }

/* ---------- Свёрнутые блоки ---------- */
.fold {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.fold > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.fold[open] > summary::after { transform: rotate(180deg); }
.fold > summary .wb-status { margin-left: auto; margin-right: 8px; font-weight: 500; }
.fold > *:not(summary) { padding: 0 16px 16px; }

/* ---------- Чат WhatsApp-стиль ---------- */
.chat-body { padding-bottom: 0; }
.chat-tabs { display: flex; gap: 8px; margin-top: 10px; }
.chat-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 20px;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.chat-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.chat-thread {
  padding: 16px 14px 150px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 60vh;
}
.chat-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  padding: 40px 20px;
}

.bubble-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.bubble-row.me { justify-content: flex-end; }
.bubble-row.them { justify-content: flex-start; }
.bubble-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px;
}
.bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}
.bubble-me { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble-them { background: var(--card); color: var(--text); border-bottom-left-radius: 4px; }
.bubble-author { font-size: 12px; font-weight: 700; margin-bottom: 2px; color: var(--primary); }
.bubble-text { white-space: pre-wrap; word-wrap: break-word; }
.bubble-time { font-size: 10px; opacity: 0.6; margin-top: 3px; text-align: right; }
.bubble-me .bubble-time { color: #e0e7ff; }
.bubble.typing { color: var(--text-muted); font-style: italic; }

.chat-input-bar {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  z-index: 20;
}
.chat-hint { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input-row textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
}
.chat-input-row textarea:focus { border-color: var(--primary); }
#chat-send {
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 17px; cursor: pointer;
}
#chat-send:disabled { opacity: 0.5; }
