/* =========================================================
   IIM AI Assistant — futuristic dark interface
   Self-hosted only (the server CSP blocks external fonts).
   ========================================================= */

:root {
  --bg: #070b18;
  --bg-2: #0b1124;
  --surface: rgba(17, 24, 48, 0.62);
  --surface-strong: rgba(22, 30, 60, 0.9);
  --surface-hover: rgba(34, 44, 84, 0.75);
  --border: rgba(148, 163, 255, 0.14);
  --border-strong: rgba(148, 163, 255, 0.28);

  --text: #e9edff;
  --text-muted: #a3aed3;
  --text-faint: #7b86ad;

  --cyan: #22d3ee;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;

  --gradient: linear-gradient(135deg, #22d3ee 0%, #6366f1 50%, #a855f7 100%);
  --glow: 0 0 0 1px rgba(99, 102, 241, 0.35), 0 8px 32px rgba(56, 189, 248, 0.18);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --header-h: 64px;
  --sidebar-w: 300px;

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    linear-gradient(rgba(148, 163, 255, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(148, 163, 255, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(ellipse at top, #0e1631 0%, var(--bg) 60%);
  background-color: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--cyan);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--cyan);
  color: #04121a;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Aurora background ---------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.aurora-blob {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.32;
  animation: drift 26s ease-in-out infinite alternate;
}

.blob-a { background: #2563eb; top: -18vmax; left: -10vmax; }
.blob-b { background: #7c3aed; bottom: -22vmax; right: -12vmax; animation-delay: -8s; }
.blob-c { background: #0891b2; top: 30%; left: 45%; width: 30vmax; height: 30vmax; opacity: 0.18; animation-delay: -15s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, 4vmax) scale(1.12); }
}

/* ---------- Header ---------- */

.app-header {
  position: relative;
  z-index: 20;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 24, 0.6);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
}

.header-left,
.header-actions,
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-orb {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--gradient);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.45);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
}

.brand-orb.small {
  width: 36px;
  height: 36px;
}

.icon-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.ghost-button {
  padding: 0 14px;
  font-size: 0.86rem;
  font-weight: 600;
}

.icon-button:hover,
.ghost-button:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.sidebar-toggle {
  display: none;
}

/* Status pill */

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}

.connection-pill.checking .connection-dot { background: var(--amber); animation: pulse 1.2s infinite; }
.connection-pill.connected { color: #b7f5dc; border-color: rgba(52, 211, 153, 0.35); }
.connection-pill.connected .connection-dot { background: var(--green); box-shadow: 0 0 10px var(--green); }
.connection-pill.fallback { color: #fde7a6; border-color: rgba(251, 191, 36, 0.35); }
.connection-pill.fallback .connection-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.connection-pill.error { color: #fecaca; border-color: rgba(248, 113, 113, 0.4); }
.connection-pill.error .connection-dot { background: var(--red); box-shadow: 0 0 10px var(--red); }

@keyframes pulse {
  50% { opacity: 0.35; }
}

/* ---------- Layout ---------- */

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100% - var(--header-h));
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: rgba(7, 11, 24, 0.35);
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 255, 0.2) transparent;
}

.panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.panel.compact {
  padding: 14px 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 0.92rem;
  font-weight: 650;
}

.panel-title.small {
  margin-bottom: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.persona-select {
  width: 100%;
  height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3aed3' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center,
    var(--bg-2);
  appearance: none;
  -webkit-appearance: none;
}

.persona-select:focus {
  border-color: var(--cyan);
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

.persona-select option {
  background: var(--bg-2);
}

.persona-hint {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.persona-hint:empty {
  display: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.08);
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.2s;
}

.chip:hover {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.1);
  color: var(--text);
  transform: translateY(-1px);
}

.trust-panel {
  display: flex;
  gap: 12px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, rgba(52, 211, 153, 0.5), rgba(34, 211, 238, 0.15)) border-box;
  border: 1px solid transparent;
}

.trust-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}

.trust-panel strong {
  font-size: 0.88rem;
}

.trust-panel p,
.about-text,
.feedback-stats {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.sidebar-footer {
  margin: auto 4px 0;
  font-size: 0.74rem;
  color: var(--text-faint);
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Chat area ---------- */

.chat-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 255, 0.2) transparent;
}

.messages,
.typing,
.welcome {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

/* Welcome */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4vh 0 24px;
  animation: rise 0.6s ease both;
}

.hero-orb {
  position: relative;
  width: 96px;
  height: 96px;
  margin-bottom: 22px;
  display: grid;
  place-items: center;
}

.hero-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #22d3ee, #6366f1, #a855f7, #ec4899, #22d3ee);
  filter: blur(1px);
  animation: spin 8s linear infinite;
  box-shadow: 0 0 60px rgba(99, 102, 241, 0.55);
}

.hero-core {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #1b2550, #0a0f22 70%);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.06em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.welcome-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.welcome-subtitle {
  max-width: 520px;
  margin: 0 0 30px;
  color: var(--text-muted);
}

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

.welcome-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 2px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: left;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.welcome-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.55);
  background: var(--surface-hover);
  box-shadow: var(--glow);
}

.card-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.icon-cyan   { background: rgba(34, 211, 238, 0.14);  color: var(--cyan); }
.icon-violet { background: rgba(139, 92, 246, 0.16);  color: #c4b5fd; }
.icon-pink   { background: rgba(236, 72, 153, 0.14);  color: #f9a8d4; }
.icon-green  { background: rgba(52, 211, 153, 0.14);  color: var(--green); }

.card-title {
  font-weight: 650;
  font-size: 0.95rem;
}

.card-text {
  font-size: 0.83rem;
  color: var(--text-muted);
}

.chat-started .welcome {
  display: none;
}

/* Messages */

.messages {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg {
  display: flex;
  gap: 12px;
  animation: rise 0.35s ease both;
}

.msg.user {
  justify-content: flex-end;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  margin-top: 2px;
  border-radius: 10px;
  background: var(--gradient);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.45);
  position: relative;
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 10px #fff;
}

.msg-body {
  min-width: 0;
  max-width: calc(100% - 44px);
}

.msg.user .msg-body {
  max-width: 80%;
}

.bubble {
  position: relative;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  overflow-wrap: anywhere;
}

.msg.bot .bubble {
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.msg.user .bubble {
  border-top-right-radius: 6px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 8px 26px rgba(79, 70, 229, 0.35);
  color: #fff;
  white-space: pre-wrap;
}

/* Markdown inside bot replies */

.bubble > :first-child { margin-top: 0; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }

.bubble h2,
.bubble h3,
.bubble h4 {
  margin: 16px 0 8px;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: #c7d2fe;
}

.bubble ul,
.bubble ol {
  margin: 6px 0 12px;
  padding-left: 20px;
}

.bubble li {
  margin: 4px 0;
}

.bubble li::marker {
  color: var(--cyan);
}

.bubble strong {
  color: #fff;
  font-weight: 650;
}

.bubble code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(148, 163, 255, 0.12);
  font-family: var(--mono);
  font-size: 0.86em;
}

.table-wrap {
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.bubble th,
.bubble td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.bubble th {
  background: rgba(99, 102, 241, 0.12);
  font-weight: 650;
  color: #c7d2fe;
}

.bubble tr:last-child td {
  border-bottom: 0;
}

/* Sources */

.sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
}

.sources-label {
  margin-right: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.08);
  font-size: 0.76rem;
  color: #b7f5dc;
}

.source-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* Quick replies */

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick button {
  padding: 7px 14px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.07);
  font-size: 0.82rem;
  color: #a5f3fc;
  transition: all 0.2s;
}

.quick button:hover {
  background: rgba(34, 211, 238, 0.16);
  border-color: var(--cyan);
  color: #fff;
}

/* Answer being written (streaming) */

.msg.streaming .bubble > :last-child::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  border-radius: 2px;
  background: var(--cyan);
  animation: stream-cursor 1s steps(1) infinite;
}

@keyframes stream-cursor {
  50% { opacity: 0; }
}

/* "Contact a human" card */

.handoff {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 12px;
  background: rgba(52, 211, 153, 0.07);
}

.handoff-title {
  display: block;
  font-size: 0.88rem;
  color: var(--text);
}

.handoff-text {
  margin: 4px 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.handoff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.handoff-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: border-color 0.2s, background 0.2s;
}

.handoff-button:hover,
.handoff-button:focus-visible {
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.14);
}

.handoff-button.whatsapp {
  border-color: rgba(52, 211, 153, 0.5);
}

.handoff-button.primary {
  border: none;
  background: var(--gradient);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.handoff-button.primary:hover,
.handoff-button.primary:focus-visible {
  background: var(--gradient);
  filter: brightness(1.1);
}

.handoff-button.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.handoff-alt-label {
  margin: 16px 0 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 0.76rem;
  color: var(--text-faint);
}

/* Enquiry form */

.enquiry-form {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
}

.enquiry-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.enquiry-field {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.enquiry-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.enquiry-field small {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.enquiry-field input,
.enquiry-field select,
.enquiry-field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(7, 11, 24, 0.6);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}

.enquiry-field textarea {
  resize: vertical;
  min-height: 90px;
}

.enquiry-field select option {
  background: #0d1428;
}

.enquiry-field input:focus-visible,
.enquiry-field select:focus-visible,
.enquiry-field textarea:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
  border-color: transparent;
}

.enquiry-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.enquiry-consent input {
  margin-top: 2px;
  accent-color: var(--green);
}

.enquiry-form > .handoff-button.primary {
  justify-self: start;
}

.enquiry-status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.enquiry-status:empty {
  display: none;
}

.enquiry-status.error {
  color: var(--red);
}

.enquiry-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.enquiry-done {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(52, 211, 153, 0.12);
}

.enquiry-done strong {
  color: var(--green);
  font-size: 0.88rem;
}

.enquiry-done p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text);
}

@media (max-width: 640px) {
  .enquiry-row {
    grid-template-columns: 1fr;
  }
}

.embed .enquiry-row {
  grid-template-columns: 1fr;
}

/* Message actions */

.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding-left: 4px;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.msg.user .msg-meta {
  justify-content: flex-end;
  padding-right: 4px;
}

.feedback {
  display: inline-flex;
  gap: 2px;
  margin-left: 6px;
}

.feedback button,
.copy-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  transition: background 0.2s, color 0.2s;
}

.feedback button:hover:not(:disabled),
.copy-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.feedback button:disabled {
  cursor: default;
  opacity: 0.4;
}

.feedback button.rated {
  opacity: 1;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.12);
}

.copy-btn.copied {
  color: var(--green);
}

/* Typing */

.typing {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-top-left-radius: 6px;
  background: var(--surface);
  font-size: 0.84rem;
  color: var(--text-muted);
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gradient);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.typing-text {
  background: linear-gradient(90deg, var(--text-faint), #e9edff, var(--text-faint));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ---------- Composer ---------- */

.composer-area {
  padding: 10px 24px 16px;
  background: linear-gradient(to top, var(--bg) 35%, transparent);
}

.chat-form {
  max-width: 820px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 8px 8px 18px;
  border: 1px solid transparent;
  border-radius: 20px;
  background:
    linear-gradient(var(--surface-strong), var(--surface-strong)) padding-box,
    linear-gradient(135deg, rgba(148, 163, 255, 0.3), rgba(148, 163, 255, 0.12)) border-box;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.25s, background 0.25s;
}

.input-wrapper:focus-within {
  background:
    linear-gradient(var(--surface-strong), var(--surface-strong)) padding-box,
    var(--gradient) border-box;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18), 0 12px 40px rgba(0, 0, 0, 0.35);
}

#chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 180px;
  padding: 9px 0;
  border: 0;
  background: transparent;
  resize: none;
  line-height: 1.5;
  outline: none;
}

#chat-input::placeholder {
  color: var(--text-faint);
}

.send-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 8px 26px rgba(99, 102, 241, 0.6);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 820px;
  margin: 8px auto 0;
  padding: 0 6px;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.privacy-note {
  max-width: 820px;
  margin: 4px auto 0;
  padding: 0 6px;
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--text-faint);
}

/* ---------- Embedded (embed.js iframe) ---------- */

.embed .aurora,
.embed .sidebar,
.embed .sidebar-toggle,
.embed .sidebar-backdrop,
.embed .brand-subtitle,
.embed .connection-text,
.embed .button-label,
.embed .powered-text,
.embed .skip-link {
  display: none;
}

.embed .app-shell {
  grid-template-columns: 1fr;
}

.embed .header-inner {
  padding: 0 12px;
  gap: 8px;
}

.embed .connection-pill {
  padding: 0 10px;
  height: 32px;
}

.embed .chat-scroll {
  padding: 16px 14px 8px;
}

.embed .composer-area {
  padding: 8px 12px 12px;
}

.embed .welcome-cards {
  grid-template-columns: 1fr;
}

.embed .msg.user .msg-body {
  max-width: 88%;
}

/* ---------- Dialog ---------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 6, 15, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dialog-box {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), var(--glow);
  animation: rise 0.25s ease both;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dialog-title-group h2 {
  margin: 0;
  font-size: 1.05rem;
}

.dialog-title-group p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.how-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.how-steps li {
  position: relative;
  padding: 10px 0 10px 40px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
  counter-increment: step;
}

.how-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
  color: #c7d2fe;
}

.how-steps strong {
  color: var(--text);
}

.dialog-note {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(320px, 86vw);
    background: rgba(9, 13, 28, 0.96);
    transform: translateX(-102%);
    transition: transform 0.3s ease;
  }

  .sidebar-open .sidebar {
    transform: none;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5);
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 30;
    background: rgba(3, 6, 15, 0.55);
  }
}

@media (max-width: 640px) {
  .header-inner { padding: 0 12px; gap: 8px; }
  .brand-subtitle,
  .button-label,
  .connection-text { display: none; }
  .connection-pill { padding: 0 10px; height: 32px; }
  .ghost-button { padding: 0 10px; }

  .chat-scroll { padding: 18px 16px 8px; }
  .composer-area { padding: 8px 12px 12px; }
  .welcome-cards { grid-template-columns: 1fr; }
  .msg.user .msg-body { max-width: 88%; }
  .powered-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
