:root {
  /* TrendAI Security palette — light theme, electric cyan/blue accent */
  --cyan: #00c2de;
  --cyan-bright: #12d7f0;
  --blue: #1466ff;
  --blue-deep: #0b3ea8;
  --navy: #0a1122;
  --navy-2: #101c33;
  --bg: #f5f8fb;
  --panel: #ffffff;
  --ink: #0f1729;
  --muted: #667085;
  --line: #e5eaf1;
  --block: #dc2626;
  --block-bg: #fff5f5;
  --allow: #0e9f6e;
  /* TrendAI brand red — used for action controls */
  --red: #e01e2b;
  --red-bright: #f43f4d;
  --red-deep: #a30f19;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: "Aptos", "Aptos Display", "Segoe UI", -apple-system,
    BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar (dark navy with cyan accent) ── */
.topbar {
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 15px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--cyan), var(--blue)) 1;
  box-shadow: 0 4px 18px rgba(10, 17, 34, 0.18);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo {
  height: 30px;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 10px rgba(0, 194, 222, 0.35));
}
.topbar h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar .accent {
  background: linear-gradient(90deg, var(--red-bright), var(--red-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
.sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: #9fb0c8;
}
.controls {
  display: flex;
  align-items: center;
  gap: 18px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(0, 194, 222, 0.14);
  border: 1px solid rgba(0, 194, 222, 0.5);
  color: var(--cyan-bright);
}
.badge-live {
  background: rgba(224, 30, 43, 0.16);
  border-color: var(--red);
  color: var(--red-bright);
}

/* ── Toggle ── */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  display: none;
}
.slider {
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .slider {
  background: linear-gradient(90deg, var(--red-bright), var(--red-deep));
}
.toggle input:checked + .slider::after {
  transform: translateX(20px);
}
.toggle-label {
  font-size: 13px;
  font-weight: 600;
}

/* ── Chat area ── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.msg {
  display: flex;
}
.msg.user {
  justify-content: flex-end;
}
.bubble {
  max-width: 76%;
  padding: 11px 15px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 41, 0.06);
}
.msg.user .bubble {
  background: linear-gradient(120deg, var(--red-bright), var(--red-deep));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg.bot .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.bubble code {
  background: rgba(20, 102, 255, 0.09);
  color: var(--blue-deep);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 13px;
}

/* ── Blocked card ── */
.blocked {
  border: 1px solid #f7caca;
  background: var(--block-bg);
  border-left: 5px solid var(--block);
  max-width: 76%;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.12);
}
.blocked .b-head {
  font-weight: 800;
  color: var(--block);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* TrendAI ring mark — shows only the red emblem (left edge of the wordmark logo) */
.blocked .b-head .mark {
  flex: none;
  width: 20px;
  height: 20px;
  background: url(/trendai-logo-inverse.png) no-repeat left center;
  background-size: auto 20px;
}
.blocked .b-reason {
  font-size: 13px;
  color: #991b1b;
  margin: 6px 0 10px;
}
.detections {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.det {
  background: #fff;
  border: 1px solid #f3d3d3;
  border-radius: 8px;
  padding: 8px 10px;
}
.det-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #991b1b;
}
.det-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.conf-bar {
  height: 6px;
  background: #fbe0e0;
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}
.conf-fill {
  height: 100%;
  background: var(--block);
  border-radius: 999px;
}
.conf-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--block);
}

/* ── Guard note under bot reply ── */
.guard-note {
  font-size: 11px;
  color: var(--allow);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.guard-note.off {
  color: var(--muted);
}

/* ── Composer ── */
.composer {
  display: flex;
  gap: 10px;
  padding: 14px 24px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
#input {
  flex: 1;
  resize: none;
  border: 1px solid #d3dbe6;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  max-height: 160px;
  color: var(--ink);
}
#input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 194, 222, 0.18);
}
#send {
  background: linear-gradient(120deg, var(--red-bright), var(--red-deep));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
#send:hover {
  filter: brightness(1.07);
}
#send:active {
  transform: translateY(1px);
}
#send:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}

.typing {
  font-style: italic;
  color: var(--muted);
}

/* ── Mobile / small screens ── */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }
  .brand {
    gap: 10px;
    min-width: 0;
  }
  .logo {
    height: 26px;
  }
  .topbar h1 {
    font-size: 17px;
  }
  .sub {
    font-size: 11px;
  }
  .controls {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }
  .chat {
    padding: 16px 14px;
    gap: 12px;
  }
  .bubble {
    max-width: 88%;
    font-size: 14px;
  }
  .blocked {
    max-width: 92%;
  }
  .composer {
    padding: 10px 12px;
    gap: 8px;
  }
  #input {
    font-size: 16px; /* 16px avoids iOS zoom-on-focus */
    padding: 10px 12px;
  }
  #send {
    padding: 0 18px;
  }
}
