/* ==========================================================================
   DIU CARE AI — admission assistant
   ========================================================================== */

:root {
  color-scheme: light;

  --page-bg: #e9f2ff;
  --app-bg: #ffffff;
  --sidebar-bg: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  --chat-bg: #f3f8ff;

  --surface: #ffffff;
  --surface-2: #eef6ff;
  --surface-3: #e1efff;
  --surface-glass: rgba(255, 255, 255, 0.78);

  --ink: #0b2340;
  --ink-2: #16395f;
  --muted: #587495;
  --muted-2: #7a93b0;

  --line: #d9e8fa;
  --line-strong: #c2dcf7;

  --brand: #007bff;
  --brand-2: #0056b3;
  --brand-3: #38bdf8;
  --brand-soft: #e6f2ff;
  --brand-softer: #f2f8ff;

  --bubble-bot: #ffffff;
  --bubble-bot-border: #dcebfb;
  --user-text: #ffffff;
  --user-gradient: linear-gradient(135deg, #007bff 0%, #0056b3 100%);

  --danger: #d92d5c;
  --danger-soft: #fde8ee;
  --success: #0f9d74;
  --success-soft: #e2f8f0;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --shadow-app: 0 40px 100px -45px rgba(9, 43, 87, 0.45);
  --shadow-card: 0 18px 40px -28px rgba(9, 43, 87, 0.4);
  --shadow-float: 0 26px 60px -24px rgba(0, 86, 179, 0.35);

  --font-display: "Poppins", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  --sidebar-w: 296px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --page-bg: #040a13;
  --app-bg: #071322;
  --sidebar-bg: linear-gradient(180deg, #09182a 0%, #06101e 100%);
  --chat-bg: #0a1727;

  --surface: #0d1f34;
  --surface-2: #10243d;
  --surface-3: #153052;
  --surface-glass: rgba(10, 23, 39, 0.82);

  --ink: #eaf4ff;
  --ink-2: #cfe3fa;
  --muted: #90a9c7;
  --muted-2: #7089a7;

  --line: rgba(139, 178, 224, 0.14);
  --line-strong: rgba(139, 178, 224, 0.26);

  --brand: #3b9dff;
  --brand-2: #1f7fe6;
  --brand-3: #7dd3fc;
  --brand-soft: rgba(59, 157, 255, 0.14);
  --brand-softer: rgba(59, 157, 255, 0.07);

  --bubble-bot: #0f2237;
  --bubble-bot-border: rgba(139, 178, 224, 0.16);

  --danger: #ff7da0;
  --danger-soft: rgba(255, 125, 160, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);

  --shadow-app: 0 40px 110px -40px rgba(0, 0, 0, 0.9);
  --shadow-card: 0 18px 44px -28px rgba(0, 0, 0, 0.8);
  --shadow-float: 0 26px 60px -24px rgba(0, 0, 0, 0.8);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  padding: 16px;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 8% -10%, rgba(0, 123, 255, 0.13), transparent 62%),
    radial-gradient(820px 600px at 100% 0%, rgba(56, 189, 248, 0.14), transparent 60%),
    radial-gradient(1000px 700px at 50% 120%, rgba(0, 86, 179, 0.12), transparent 65%);
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, p { margin: 0; }
h2, h3 { font-family: var(--font-display); }
ul { margin: 0; }

[hidden] { display: none !important; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

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

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection { background: rgba(0, 123, 255, 0.22); }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.62rem;
  line-height: 1;
}

/* ---------- app shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  width: 100%;
  max-width: 1520px;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--app-bg);
  box-shadow: var(--shadow-app);
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.crest { display: inline-grid; place-items: center; flex: none; }
.crest svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 10px rgba(0, 86, 179, 0.22)); }
.crest--lg { width: 42px; height: 42px; }
.crest--sm { width: 40px; height: 40px; }
.crest--xs { width: 30px; height: 30px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  flex: none;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { background: var(--brand-soft); border-color: var(--line-strong); color: var(--brand); }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(15, 157, 116, 0.14);
  flex: none;
}

/* ---------- sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sidebar-brand-copy { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.sidebar-brand-copy strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.sidebar-brand-copy span {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.sidebar-close { display: none; width: 34px; height: 34px; }

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.sidebar-scroll.is-scrollable {
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent 100%);
}

.status-card {
  padding: 11px 13px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}
.status-card p { margin-top: 5px; font-size: 0.68rem; line-height: 1.45; color: var(--muted-2); }

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  box-shadow: 0 12px 24px -16px rgba(0, 86, 179, 0.8);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.new-chat:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 18px 30px -16px rgba(0, 86, 179, 0.9); }
.new-chat svg { flex: none; }
.new-chat-key {
  margin-left: auto;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.6rem;
  font-weight: 600;
}

.side-section { margin-top: 14px; }
.side-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
  margin-bottom: 8px;
}
.side-heading h2 {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.side-heading > span {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--muted-2);
  background: var(--surface-2);
  border-radius: 99px;
  padding: 1px 7px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 136px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.history-empty { padding: 10px 8px; font-size: 0.72rem; color: var(--muted-2); line-height: 1.5; }

.history-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.history-item:hover { background: var(--surface); }
.history-item.is-active { background: var(--brand-soft); border-color: var(--line-strong); }
.history-item.is-active .hi-icon { color: var(--brand); background: var(--surface); }

.hi-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted-2);
  flex: none;
}
.hi-body { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.hi-body strong {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hi-body span {
  font-size: 0.64rem;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hi-time { font-size: 0.56rem; color: var(--muted-2); flex: none; }

.topic-list { display: flex; flex-direction: column; gap: 1px; }
.topic-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease;
}
.topic-link svg { color: var(--brand); opacity: 0.8; flex: none; }
.topic-link:hover { background: var(--surface); color: var(--ink); }

.handoff-card {
  position: relative;
  flex: none;
  margin: 0 14px 12px;
  padding: 16px;
  border-radius: 14px;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(56, 189, 248, 0.4), transparent 56%),
    linear-gradient(140deg, #007bff 0%, #0056b3 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-float);
}
.handoff-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -44px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 20px solid rgba(255, 255, 255, 0.08);
}
.handoff-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.16);
}
.handoff-card h2 { font-size: 0.92rem; font-weight: 600; margin-bottom: 4px; }
.handoff-card p { font-size: 0.7rem; line-height: 1.5; color: rgba(255, 255, 255, 0.82); margin-bottom: 12px; }
.handoff-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.18s ease;
}
.handoff-btn:hover { background: rgba(255, 255, 255, 0.26); transform: translateY(-1px); }

.sidebar-foot {
  flex: none;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease;
}
.theme-toggle:hover { background: var(--surface); color: var(--ink); }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
.sidebar-foot p { margin-top: 4px; padding: 0 8px; font-size: 0.6rem; color: var(--muted-2); }

/* ---------- chat shell ---------- */

.chat-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
  transition: background 0.3s ease;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px clamp(16px, 2.6vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  flex: none;
  z-index: 5;
}

.menu-btn { display: none; }

.assistant-id { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.assistant-copy { min-width: 0; }
.assistant-copy h1 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.demo-badge {
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--font-body);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.assistant-copy p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 0.66rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.kb-chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ---------- welcome ---------- */

.welcome {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  background:
    radial-gradient(760px 420px at 86% 4%, rgba(0, 123, 255, 0.1), transparent 62%),
    radial-gradient(600px 380px at 4% 96%, rgba(56, 189, 248, 0.1), transparent 64%);
}
.welcome::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 123, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 123, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 34%, #000 12%, transparent 68%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 34%, #000 12%, transparent 68%);
  pointer-events: none;
}

.welcome-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 860px;
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(28px, 5vh, 52px) clamp(20px, 4vw, 42px);
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 5px 11px;
  margin-bottom: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--brand-2);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: var(--shadow-card);
}
.welcome-badge svg { color: var(--brand); }

.welcome h2 {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.035em;
  margin-bottom: 14px;
}
.welcome h2 span {
  background: linear-gradient(100deg, var(--brand) 0%, #38bdf8 55%, var(--brand-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-sub {
  max-width: 62ch;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.1vw, 1rem);
  line-height: 1.65;
  margin-bottom: 24px;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.quick-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.quick-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card);
  background: var(--brand-softer);
}
.quick-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.quick-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.quick-copy strong { font-size: 0.79rem; font-weight: 600; color: var(--ink); }
.quick-copy small { font-size: 0.66rem; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-arrow { color: var(--muted-2); flex: none; transition: transform 0.18s ease, color 0.18s ease; }
.quick-card:hover .quick-arrow { transform: translateX(3px); color: var(--brand); }

.welcome-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 0.64rem;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.welcome-meta span { display: inline-flex; align-items: center; gap: 6px; }
.welcome-meta span::before { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }
.welcome-meta span:first-child::before { display: none; }

/* ---------- chat ---------- */

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.chat-shell:not(.is-chat) .chat-scroll { display: none; }
.chat-shell.is-chat .welcome { display: none; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 30px) clamp(16px, 3.4vw, 38px) 10px;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: msgIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.msg--user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--line);
}
.msg-avatar svg { width: 100%; height: 100%; }
.msg--user .msg-avatar {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
}
.msg-avatar--user svg { width: 17px; height: 17px; }

.msg-body { display: flex; flex-direction: column; min-width: 0; max-width: min(660px, 82%); }
.msg--user .msg-body { align-items: flex-end; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  padding: 0 2px;
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  color: var(--muted-2);
}
.msg-meta strong { font-weight: 600; color: var(--ink-2); font-size: 0.64rem; }
.msg-meta time { font-variant-numeric: tabular-nums; }
.msg-tag {
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  text-transform: uppercase;
}

.msg-bubble {
  padding: 11px 14px;
  border: 1px solid var(--bubble-bot-border);
  border-radius: 4px 14px 14px 14px;
  background: var(--bubble-bot);
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.62;
  box-shadow: 0 1px 2px rgba(9, 43, 87, 0.04);
  overflow-wrap: anywhere;
}
.msg--user .msg-bubble {
  border: 0;
  border-radius: 14px 4px 14px 14px;
  background: var(--user-gradient);
  color: var(--user-text);
  box-shadow: 0 10px 24px -14px rgba(0, 86, 179, 0.8);
}
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 600; color: var(--ink); }
.msg--user .msg-bubble strong { color: #fff; }
.msg-bubble em { font-style: italic; }
.msg-bubble a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.msg-bubble a:hover { color: var(--brand-2); }
.msg-bubble ul,
.msg-bubble ol { margin: 6px 0 8px; padding-left: 18px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble li::marker { color: var(--brand); }
.msg-bubble br { display: block; content: ""; margin: 3px 0; }
.msg-bubble code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 0.84em;
}

.msg-actions { display: flex; align-items: center; gap: 4px; margin-top: 5px; padding: 0 2px; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted-2);
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.msg:hover .copy-btn, .copy-btn:focus-visible, .copy-btn.copied { opacity: 1; }
.copy-btn:hover { background: var(--surface-2); color: var(--brand); }
.copy-btn svg { width: 12px; height: 12px; }

/* typing */

.typing-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3.4vw, 38px) 12px;
  animation: msgIn 0.25s ease both;
}
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--bubble-bot-border);
  border-radius: 4px 14px 14px 14px;
  background: var(--bubble-bot);
}
.typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.4;
  animation: typing 1.2s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

/* ---------- composer ---------- */

.composer-area {
  flex: none;
  padding: 8px clamp(16px, 3.4vw, 38px) 12px;
  background: linear-gradient(180deg, transparent 0%, var(--chat-bg) 32%);
}

.suggestions {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 8px;
  min-width: 0;
}
.suggest-label {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
  flex: none;
}
.suggestion-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.suggestion-chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  max-width: 250px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
  animation: chipIn 0.25s ease both;
}
.chip:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.chip--action { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip--action:hover { background: var(--brand-2); color: #fff; }
.chip svg { flex: none; width: 12px; height: 12px; }

.composer { max-width: 900px; margin: 0 auto; }
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 16px 36px -26px rgba(9, 43, 87, 0.55);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.composer-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.12), 0 16px 36px -26px rgba(9, 43, 87, 0.55);
}
.composer-spark { color: var(--brand); flex: none; margin-bottom: 10px; }
.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.5;
  resize: none;
  outline: none;
}
.composer textarea::placeholder { color: var(--muted-2); }

.send-btn {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  flex: none;
  box-shadow: 0 8px 18px -10px rgba(0, 86, 179, 0.9);
  transition: transform 0.16s ease, opacity 0.16s ease, filter 0.16s ease;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.send-btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.send-btn:disabled { opacity: 0.38; box-shadow: none; cursor: not-allowed; }

.composer-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 900px;
  margin: 7px auto 0;
  padding: 0 2px;
  font-size: 0.58rem;
  color: var(--muted-2);
}
.composer-foot kbd { height: 16px; min-width: 16px; font-size: 0.55rem; }

/* ---------- drawer scrim ---------- */

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 12, 24, 0.5);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease both;
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 12, 24, 0.58);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.22s ease both;
}
.modal-card {
  position: relative;
  width: min(540px, 100%);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  padding: clamp(22px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--app-bg);
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.55);
  animation: modalIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  scrollbar-width: thin;
}
.modal-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; }
.modal-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
}
.modal-card > h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.modal-sub { margin-top: 3px; margin-bottom: 18px; font-size: 0.76rem; color: var(--muted); }

.contact-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.contact-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  transition: border-color 0.16s ease, background 0.16s ease;
}
a.contact-row:hover { border-color: var(--brand); background: var(--brand-softer); }
.contact-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.contact-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.contact-copy small { font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); }
.contact-copy strong { font-size: 0.78rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.contact-go { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); flex: none; }
.contact-row--static { cursor: default; }

.callback { padding-top: 16px; border-top: 1px solid var(--line); }
.callback h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 3px; }
.callback-sub { font-size: 0.7rem; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.callback-sub em { color: var(--muted-2); font-style: normal; font-weight: 500; }

.callback-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.callback-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.callback-wide { grid-column: 1 / -1; }
.callback-grid input,
.callback-grid select {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.callback-grid input:focus,
.callback-grid select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.12);
}
.form-error {
  margin-top: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.7rem;
  font-weight: 500;
}
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: 11px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  box-shadow: 0 12px 26px -16px rgba(0, 86, 179, 0.9);
  transition: transform 0.16s ease, filter 0.16s ease;
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.modal-note { margin-top: 14px; text-align: center; font-size: 0.6rem; color: var(--muted-2); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  transform: translate(-50%, 16px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(7, 26, 48, 0.96);
  color: #fff;
  font-size: 0.76rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- motion ---------- */

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes chipIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- responsive ---------- */

@media (max-height: 900px) {
  .handoff-card { padding: 13px 14px; }
  .handoff-card p { display: none; }
  .handoff-icon { margin-bottom: 7px; }
  .handoff-card h2 { margin-bottom: 8px; }
}

@media (max-width: 1180px) {
  :root { --sidebar-w: 268px; }
  .welcome-inner { max-width: 760px; }
}

@media (max-width: 960px) {
  body { padding: 0; }
  .app {
    grid-template-columns: 1fr;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    border: 0;
    border-radius: 0;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: min(322px, 88vw);
    border-radius: 0 20px 20px 0;
    border-right: 1px solid var(--line);
    transform: translateX(-104%);
    box-shadow: 30px 0 80px -40px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }
  .status-card { padding: 9px 12px; margin-bottom: 10px; }
  .status-card p { display: none; }
  .chat-header { min-height: 66px; padding: 10px 14px; }
  .assistant-id { gap: 9px; }
  .assistant-copy h1 { font-size: 0.96rem; }
  .crest--sm { width: 36px; height: 36px; }
  .kb-chip { display: none; }
  .welcome-inner { max-width: 680px; }
}

@media (max-width: 700px) {
  .header-actions .icon-btn { width: 35px; height: 35px; }
  .welcome-inner { padding: 26px 18px 22px; }
  .welcome h2 { font-size: clamp(1.9rem, 8.4vw, 2.5rem); }
  .welcome-sub { font-size: 0.88rem; margin-bottom: 18px; }
  .quick-grid { grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; }
  .quick-card { padding: 10px 11px; }
  .quick-icon { width: 34px; height: 34px; }
  .messages { padding: 16px 12px 6px; gap: 16px; }
  .msg-body { max-width: 86%; }
  .msg-bubble { font-size: 0.84rem; padding: 10px 12px; }
  .msg-avatar { width: 28px; height: 28px; }
  .typing-row { padding: 0 12px 10px; }
  .composer-area { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .composer-box { padding-left: 11px; }
  .suggest-label { display: none; }
  .composer textarea { font-size: 16px; }
  .composer-foot span:last-child { display: none; }
  .composer-foot { justify-content: center; }
  .suggestions { margin-bottom: 6px; }
  .chip { max-width: 210px; font-size: 0.64rem; }
  .modal-card { padding: 22px 18px; border-radius: 20px; }
  .callback-grid { grid-template-columns: 1fr; }
  .callback-wide { grid-column: auto; }
  .copy-btn { opacity: 1; }
}

@media (max-width: 400px) {
  .assistant-copy p { max-width: 150px; }
  .assistant-copy h1 { font-size: 0.9rem; }
  .demo-badge { display: none; }
  .header-actions { gap: 5px; }
  .welcome-meta { gap: 6px 10px; font-size: 0.58rem; }
  .quick-copy small { font-size: 0.62rem; }
  .msg-body { max-width: 88%; }
}

@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;
  }
  .typing-dots i { opacity: 0.7; }
}
