* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

body {
  margin: 0;
  background: #0f172a;
  color: #1e293b;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.sim-topbar {
  background: #0f172a;
  color: #f8fafc;
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #1e293b;
}

.topbar-right, .topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.back-link {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
}

.sim-badge {
  background: #1e293b;
  color: #38bdf8;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.tool-btn {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}

.tool-accent {
  background: #0284c7;
  border-color: #0284c7;
}

.tool-cta {
  background: #10b981;
  border-color: #10b981;
  color: #064e3b;
  font-weight: 800;
}

.mobile-switcher {
  display: none;
  background: #1e293b;
  padding: 0.4rem;
  gap: 0.4rem;
}

.switch-tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 8px;
  background: #334155;
  color: #e2e8f0;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}

.switch-tab.active {
  background: #38bdf8;
  color: #0f172a;
}

.unread-badge {
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  margin-right: 0.25rem;
}

.hidden {
  display: none !important;
}

.sim-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  padding: 0.5rem;
  gap: 0.35rem;
}

.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.chat-header {
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #ffffff;
}

.tg-header {
  background: #2481cc;
}

.wa-header {
  background: #075e54;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.2);
}

.header-info {
  flex: 1;
}

.header-title {
  font-weight: 800;
  font-size: 0.98rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bot-tag {
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.wa-verified {
  background: #25d366;
  color: #075e54;
  font-size: 0.72rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
}

.header-sub {
  font-size: 0.78rem;
  opacity: 0.9;
}

.header-pill {
  background: rgba(0, 0, 0, 0.22);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tg-messages {
  background: #e6ebee;
}

.wa-messages {
  background: #efeae2;
}

.msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.msg-wrap.bot {
  align-self: flex-start;
}

.msg-wrap.user {
  align-self: flex-end;
}

.msg-bubble {
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-line;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.tg-messages .msg-wrap.bot .msg-bubble {
  background: #ffffff;
  border-top-right-radius: 2px;
}

.tg-messages .msg-wrap.user .msg-bubble {
  background: #effdde;
  border-top-left-radius: 2px;
}

.wa-messages .msg-wrap.bot .msg-bubble {
  background: #ffffff;
  border-top-right-radius: 2px;
}

.wa-messages .msg-wrap.user .msg-bubble {
  background: #d9fdd3;
  border-top-left-radius: 2px;
}

.msg-time {
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 0.2rem;
  align-self: flex-end;
}

.inline-keyboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.tg-inline-btn {
  background: rgba(36, 129, 204, 0.14);
  color: #1665a8;
  border: 1px solid rgba(36, 129, 204, 0.35);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.tg-inline-btn:hover {
  background: #2481cc;
  color: #ffffff;
}

.wa-inline-btn {
  background: #ffffff;
  color: #008069;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.48rem 0.65rem;
  font-weight: 700;
  font-size: 0.83rem;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.wa-inline-btn:hover {
  background: #008069;
  color: #ffffff;
}

.sync-divider {
  text-align: center;
  font-size: 0.78rem;
  color: #94a3b8;
  padding: 0.15rem 0.5rem;
  transition: color 0.25s;
}

.sync-divider.flash {
  color: #38bdf8;
  font-weight: 700;
}

.quick-commands {
  display: flex;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  overflow-x: auto;
}

.quick-commands button {
  white-space: nowrap;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
}

.chat-input-bar {
  display: flex;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  background: #f1f5f9;
}

.chat-input-bar input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
  outline: none;
}

.send-btn {
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.tg-send { background: #2481cc; }
.wa-send { background: #008069; }

@media (max-width: 768px) {
  .mobile-switcher {
    display: flex;
  }
  .sim-workspace.mode-tg .wa-pane,
  .sim-workspace.mode-tg .sync-divider {
    display: none;
  }
  .sim-workspace.mode-wa .tg-pane,
  .sim-workspace.mode-wa .sync-divider {
    display: none;
  }
}
