/* ============================================
   betterweb — AI Website Intelligence
   Aesthetic: Liquid Precision
   Dark violet + Light mode toggle
   ============================================ */

:root {
  /* Backgrounds */
  --bg-deep: #09090B;
  --bg-surface: #111113;
  --bg-card: #18181B;
  --bg-card-hover: #1F1F23;
  --bg-input: #0C0C0E;
  --bg-input-focus: #111113;

  /* Violet palette */
  --violet-950: #1E103A;
  --violet-800: #3B1F8E;
  --violet-700: #5B21B6;
  --violet-600: #7C3AED;
  --violet-500: #8B5CF6;
  --violet-400: #A78BFA;
  --violet-300: #C4B5FD;
  --violet-glow: rgba(139, 92, 246, 0.12);
  --violet-glow-strong: rgba(139, 92, 246, 0.25);

  /* Text */
  --text-primary: #FFFFFF;
  --text-secondary: #FFFFFF;
  --text-muted: #E4E4E7;
  --text-accent: #A78BFA;

  /* Borders */
  --border-subtle: rgba(139, 92, 246, 0.06);
  --border-default: rgba(139, 92, 246, 0.12);
  --border-focus: rgba(139, 92, 246, 0.35);

  /* Effects */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.06);

  /* Typography */
  --font-display: "Instrument Serif", "Playfair Display", "Georgia", "Times New Roman", serif;
  --font-body: "Outfit", "DM Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "Berkeley Mono", "JetBrains Mono", "SF Mono", "Cascadia Code", "Fira Code", monospace;

  /* Sizing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);

  color-scheme: dark;
}

/* ---- Light Mode ---- */
html.light {
  --bg-deep: #FAFAFA;
  --bg-surface: #FFFFFF;
  --bg-card: #F4F4F5;
  --bg-card-hover: #E4E4E7;
  --bg-input: #FFFFFF;
  --bg-input-focus: #FFFFFF;

  --text-primary: #0A0A0B;
  --text-secondary: #18181B;
  --text-muted: #27272A;
  --text-accent: #7C3AED;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-focus: rgba(124, 58, 237, 0.4);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.04);

  --violet-glow: rgba(124, 58, 237, 0.06);
  --violet-glow-strong: rgba(124, 58, 237, 0.12);

  color-scheme: light;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--violet-400); text-decoration: none; }
a:hover { color: var(--violet-300); }
html.light a { color: var(--violet-600); }
html.light a:hover { color: var(--violet-700); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--violet-950); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--violet-800); }
html.light ::-webkit-scrollbar-thumb { background: #D4D4D8; }
html.light ::-webkit-scrollbar-thumb:hover { background: #A1A1AA; }

/* ---- Theme Toggle ---- */
.btn-theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  cursor: pointer;
  padding: 7px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s var(--ease-out);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.btn-theme-toggle:hover {
  color: var(--violet-400);
  border-color: var(--border-focus);
  background: var(--violet-glow-strong);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.12);
}

html.light .btn-theme-toggle:hover {
  color: var(--violet-600);
}

.btn-theme-toggle .icon-sun,
.btn-theme-toggle .icon-moon { display: none; }
.btn-theme-toggle .icon-moon { display: flex; }
html.light .btn-theme-toggle .icon-moon { display: none; }
html.light .btn-theme-toggle .icon-sun { display: flex; }

.btn-theme-toggle .theme-label-light { display: none; }
html.light .btn-theme-toggle .theme-label-dark { display: none; }
html.light .btn-theme-toggle .theme-label-light { display: inline; }

/* Animated border angle for login card */
@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% 50%, rgba(124, 58, 237, 0.05) 0%, transparent 70%),
    var(--bg-deep);
}

/* Animated background orbs — vivid violet glow */
.login-shell::before,
.login-shell::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  will-change: transform;
  pointer-events: none;
}

.login-shell::before {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.40) 0%, rgba(139, 92, 246, 0.12) 45%, transparent 72%);
  filter: blur(70px);
  top: -20%;
  left: -15%;
  animation: orbDrift1 20s ease-in-out infinite;
}

.login-shell::after {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, rgba(167, 139, 250, 0.10) 45%, transparent 72%);
  filter: blur(70px);
  bottom: -20%;
  right: -15%;
  animation: orbDrift2 25s ease-in-out infinite;
}

@keyframes orbDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(12vw, 8vh) scale(1.15); }
  50% { transform: translate(5vw, 20vh) scale(0.95); }
  75% { transform: translate(-8vw, 12vh) scale(1.08); }
}

@keyframes orbDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-10vw, -6vh) scale(1.08); }
  50% { transform: translate(-4vw, -18vh) scale(1.15); }
  75% { transform: translate(8vw, -8vh) scale(0.95); }
}

html.light .login-shell::before {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.18) 0%, rgba(139, 92, 246, 0.06) 45%, transparent 72%);
}

html.light .login-shell::after {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.14) 0%, rgba(167, 139, 250, 0.04) 45%, transparent 72%);
}

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  padding: 48px 40px 40px;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(var(--bg-surface), var(--bg-surface)) padding-box,
    conic-gradient(
      from var(--border-angle),
      transparent 0%,
      rgba(139, 92, 246, 0.06) 4%,
      var(--violet-400) 10%,
      var(--violet-300) 15%,
      var(--violet-400) 20%,
      rgba(139, 92, 246, 0.06) 26%,
      transparent 32%,
      transparent 100%
    ) border-box;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 24px 80px rgba(0, 0, 0, 0.3),
    0 0 50px rgba(139, 92, 246, 0.08),
    0 0 100px rgba(139, 92, 246, 0.04);
  animation: cardEnter 0.6s var(--ease-out) both, borderSpin 4s linear 0.6s infinite;
}

html.light .login-card {
  background:
    linear-gradient(var(--bg-surface), var(--bg-surface)) padding-box,
    conic-gradient(
      from var(--border-angle),
      transparent 0%,
      rgba(124, 58, 237, 0.08) 4%,
      var(--violet-600) 10%,
      var(--violet-400) 15%,
      var(--violet-600) 20%,
      rgba(124, 58, 237, 0.08) 26%,
      transparent 32%,
      transparent 100%
    ) border-box;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.04),
    0 8px 32px rgba(0, 0, 0, 0.06),
    0 24px 80px rgba(0, 0, 0, 0.05),
    0 0 50px rgba(124, 58, 237, 0.04);
}

@keyframes borderSpin {
  to { --border-angle: 360deg; }
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Brand */
.login-brand {
  text-align: center;
  margin-bottom: 40px;
}

.login-brand-mark {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.brand-logo {
  flex-shrink: 0;
}

/* Logo swapping: dark mode = white logo, light mode = black logo */
.brand-logo-light { display: none; }
html.light .brand-logo-dark { display: none; }
html.light .brand-logo-light { display: inline; }

.login-brand-mark span {
  color: var(--violet-500);
}

html.light .login-brand-mark span {
  color: var(--violet-600);
}

.login-brand-tagline {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 10px;
}

/* Divider — subtle spacing only */
.login-divider {
  width: 0;
  height: 0;
  margin: 0 auto 8px;
}

/* Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.25s var(--ease-out);
}

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

html.light .form-input::placeholder {
  color: #71717A;
  opacity: 0.7;
}

.form-input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--violet-glow);
}

/* Button */
.btn-login {
  width: 100%;
  padding: 12px 24px;
  margin-top: 4px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--violet-600);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s var(--ease-out);
}

.btn-login::before { display: none; }

.btn-login:hover {
  background: var(--violet-500);
  box-shadow: 0 0 24px rgba(139, 92, 246, 0.2);
  transform: translateY(-1px);
}

.btn-login:active {
  transform: translateY(0);
}

.btn-login:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Error */
.login-error {
  display: none;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.12);
  border-radius: var(--radius-sm);
  text-align: center;
  animation: errorShake 0.4s var(--ease-out);
}

html.light .login-error {
  color: #DC2626;
  background: rgba(239, 68, 68, 0.06);
}

.login-error.visible {
  display: block;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Login floating theme toggle (top-right) */
.login-theme-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10;
}

/* Footer */
.login-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.login-footer p {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Login mobile — see consolidated mobile section below */

/* ============================================
   CHAT PAGE — Layout
   ============================================ */

.chat-shell {
  display: flex;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height for mobile browsers */
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 272px;
  min-width: 272px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s var(--ease-out);
  z-index: 10;
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-brand {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-brand span {
  color: var(--violet-500);
}

html.light .sidebar-brand span {
  color: var(--violet-600);
}

.btn-new-chat {
  width: 100%;
  padding: 9px 14px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.btn-new-chat:hover {
  background: var(--violet-glow);
  border-color: var(--border-focus);
  color: var(--violet-400);
}

html.light .btn-new-chat {
  color: var(--violet-700);
  border-color: rgba(124, 58, 237, 0.2);
}

html.light .btn-new-chat:hover {
  color: var(--violet-600);
  background: rgba(124, 58, 237, 0.06);
  border-color: rgba(124, 58, 237, 0.35);
}

/* Conversation list */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  margin-bottom: 1px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.conv-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.conv-item.active {
  background: var(--bg-card);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.conv-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.78rem;
  border-radius: 3px;
  transition: all 0.15s;
}

.conv-item:hover .conv-item-delete {
  opacity: 1;
}

.conv-item-delete:hover {
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.08);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--violet-950);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--violet-400);
}

html.light .sidebar-avatar {
  background: rgba(124, 58, 237, 0.08);
  color: var(--violet-600);
}

.sidebar-username {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* ---- Main Chat Area ---- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(ellipse 70% 55% at 0% 100%, rgba(139, 92, 246, 0.08) 0%, transparent 65%),
    radial-gradient(ellipse 55% 50% at 100% 0%, rgba(91, 33, 182, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(139, 92, 246, 0.03) 0%, transparent 75%),
    var(--bg-deep);
  position: relative;
}

html.light .chat-main {
  background:
    radial-gradient(ellipse 70% 55% at 0% 100%, rgba(124, 58, 237, 0.06) 0%, transparent 65%),
    radial-gradient(ellipse 55% 50% at 100% 0%, rgba(91, 33, 182, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(124, 58, 237, 0.025) 0%, transparent 75%),
    var(--bg-deep);
}

/* Top bar */
.chat-topbar {
  height: 54px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
  gap: 12px;
}

.chat-topbar-title {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.chat-topbar-model {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--violet-400);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  background: var(--violet-glow);
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

html.light .chat-topbar-model {
  color: var(--violet-700);
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.15);
}

/* Topbar actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-nav-link {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid transparent;
  transition: all 0.2s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.topbar-nav-link:hover {
  color: var(--violet-400);
  background: var(--violet-glow);
  border-color: var(--border-subtle);
}

html.light .topbar-nav-link {
  color: var(--violet-700);
}

html.light .topbar-nav-link:hover {
  color: var(--violet-600);
  background: rgba(124, 58, 237, 0.06);
}

.topbar-nav-link svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 4px;
}

/* Mobile sidebar toggle */
.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  font-size: 1.1rem;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

/* Removed noise texture — gradients on .chat-main handle the depth */

/* Welcome screen */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.chat-welcome-icon {
  margin-bottom: 20px;
  opacity: 0.3;
}

.chat-welcome h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.chat-welcome p {
  font-size: 0.84rem;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.7;
}

/* Welcome screen — animated gradient orbs */
.chat-welcome {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.chat-welcome::before,
.chat-welcome::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  will-change: transform;
  pointer-events: none;
  z-index: -1;
}

.chat-welcome::before {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.28) 0%, rgba(139, 92, 246, 0.08) 45%, transparent 72%);
  filter: blur(90px);
  bottom: -15%;
  left: -5%;
  animation: welcomeOrb1 22s ease-in-out infinite;
}

.chat-welcome::after {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(91, 33, 182, 0.22) 0%, rgba(124, 58, 237, 0.06) 45%, transparent 72%);
  filter: blur(90px);
  top: -10%;
  right: -5%;
  animation: welcomeOrb2 28s ease-in-out infinite;
}

@keyframes welcomeOrb1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(8vw, -8vh) scale(1.1); }
  66% { transform: translate(-4vw, 5vh) scale(0.95); }
}

@keyframes welcomeOrb2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-6vw, 6vh) scale(1.08); }
  66% { transform: translate(5vw, -5vh) scale(1.12); }
}

html.light .chat-welcome::before {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.14) 0%, rgba(139, 92, 246, 0.04) 45%, transparent 72%);
}

html.light .chat-welcome::after {
  background: radial-gradient(circle, rgba(91, 33, 182, 0.10) 0%, rgba(124, 58, 237, 0.03) 45%, transparent 72%);
}

.chat-welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
  justify-content: center;
  max-width: 600px;
}

.suggestion-chip {
  padding: 8px 16px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.suggestion-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-default);
  color: var(--text-primary);
}

html.light .suggestion-chip {
  color: var(--violet-700);
  background: rgba(124, 58, 237, 0.05);
  border-color: rgba(124, 58, 237, 0.15);
}

html.light .suggestion-chip:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.3);
  color: var(--violet-800);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.08);
}

/* Message bubbles */
.message {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 4px 0;
  animation: msgFadeIn 0.25s var(--ease-out) both;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); filter: blur(2px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.message-user {
  display: flex;
  justify-content: flex-end;
}

.message-user .message-content {
  background: var(--violet-950);
  border: 1px solid rgba(139, 92, 246, 0.1);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-md);
  padding: 11px 16px;
  max-width: 75%;
  font-size: 0.86rem;
  line-height: 1.6;
}

html.light .message-user .message-content {
  background: rgba(124, 58, 237, 0.06);
  border-color: rgba(124, 58, 237, 0.1);
}

.message-assistant .message-content {
  padding: 14px 8px 14px 16px;
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--text-primary);
  border-left: 2px solid var(--violet-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: linear-gradient(90deg, var(--violet-glow) 0%, transparent 40%);
}

html.light .message-assistant .message-content {
  border-left-color: var(--violet-500);
}

/* Smooth reveal animation for streaming text */
.message-assistant .message-content.streaming-cursor {
  animation: contentReveal 0.3s var(--ease-out) both;
}

@keyframes contentReveal {
  from { opacity: 0.5; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Markdown in assistant messages */
.message-assistant .message-content h1,
.message-assistant .message-content h2,
.message-assistant .message-content h3 {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: 6px;
  margin: 20px 0 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.message-assistant .message-content h1 { font-size: 1.15rem; }
.message-assistant .message-content h2 { font-size: 1.05rem; }
.message-assistant .message-content h3 {
  font-size: 0.92rem;
  border-bottom: none;
  color: var(--violet-300);
}

html.light .message-assistant .message-content h3 {
  color: var(--violet-700);
}

.message-assistant .message-content p {
  margin: 10px 0;
}

.message-assistant .message-content ul,
.message-assistant .message-content ol {
  margin: 10px 0;
  padding-left: 22px;
}

.message-assistant .message-content li {
  margin: 6px 0;
  line-height: 1.65;
}

.message-assistant .message-content li::marker {
  color: var(--violet-500);
}

.message-assistant .message-content strong {
  color: var(--violet-300);
  font-weight: 600;
}

html.light .message-assistant .message-content strong {
  color: var(--violet-700);
}

.message-assistant .message-content em {
  color: var(--text-muted);
  font-style: italic;
}

.message-assistant .message-content code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  padding: 2px 7px;
  background: var(--bg-card);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: var(--violet-300);
}

html.light .message-assistant .message-content code {
  color: var(--violet-700);
}

.message-assistant .message-content pre {
  margin: 14px 0;
  padding: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  position: relative;
}

.message-assistant .message-content pre::before {
  content: "CODE";
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  opacity: 0.4;
}

.message-assistant .message-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text-primary);
}

/* Tables */
.message-assistant .message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.message-assistant .message-content th {
  text-align: left;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--violet-400);
  background: var(--bg-surface);
  border-bottom: 2px solid var(--violet-600);
}

html.light .message-assistant .message-content th {
  color: var(--violet-700);
  border-bottom-color: var(--violet-500);
}

.message-assistant .message-content td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.message-assistant .message-content tr:hover td {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Links in messages */
.message-assistant .message-content a {
  color: var(--violet-400);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(167, 139, 250, 0.3);
  transition: all 0.15s;
}

.message-assistant .message-content a:hover {
  color: var(--violet-300);
  text-decoration-color: var(--violet-400);
}

html.light .message-assistant .message-content a {
  color: var(--violet-600);
  text-decoration-color: rgba(124, 58, 237, 0.3);
}

html.light .message-assistant .message-content a:hover {
  color: var(--violet-700);
}

/* Thinking indicator — morphing gradient blob */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 4px;
  animation: msgFadeIn 0.4s var(--ease-out) both;
}

.thinking-blob-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

/* Glow behind blob */
.thinking-blob-wrap::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, transparent 70%);
  animation: blobGlow 2s ease-in-out infinite;
  filter: blur(6px);
}

.thinking-blob {
  width: 100%;
  height: 100%;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  background: linear-gradient(135deg, var(--violet-600), var(--violet-400), var(--violet-500));
  background-size: 200% 200%;
  animation:
    morphBlob 4s ease-in-out infinite,
    blobGradient 3s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  position: relative;
}

/* Inner highlight */
.thinking-blob::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: radial-gradient(ellipse at 35% 30%, rgba(255, 255, 255, 0.25) 0%, transparent 60%);
}

@keyframes morphBlob {
  0%, 100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
  25%      { border-radius: 58% 42% 75% 25% / 76% 46% 54% 24%; }
  50%      { border-radius: 50% 50% 33% 67% / 55% 27% 73% 45%; }
  75%      { border-radius: 33% 67% 58% 42% / 63% 68% 32% 37%; }
}

@keyframes blobGradient {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

@keyframes blobGlow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.15); }
}

.thinking-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thinking-label {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  opacity: 0.85;
}

.thinking-shimmer-bar {
  height: 2px;
  width: 100px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--violet-500), var(--violet-400), transparent);
  background-size: 200% 100%;
  animation: shimmerFlow 1.8s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes shimmerFlow {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

html.light .thinking-blob-wrap::before {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.2) 0%, transparent 70%);
}

html.light .thinking-blob {
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.2);
}

/* Tool indicator */
.tool-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  margin: 6px auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  max-width: 800px;
  width: fit-content;
  animation: msgFadeIn 0.25s var(--ease-out) both;
}

.tool-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet-500);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
  animation: toolPulse 1.5s infinite;
}

@keyframes toolPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.tool-indicator.done {
  opacity: 0.5;
  transition: opacity 0.3s;
}

.tool-indicator.done .tool-indicator-dot {
  animation: none;
  opacity: 0.4;
  box-shadow: none;
}

/* Streaming cursor — smooth Cursor-style blink */
.streaming-cursor::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--violet-400);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: cursorFade 1s ease-in-out infinite;
}

@keyframes cursorFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

/* Follow-up suggestion chips after assistant messages */
.follow-up-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 800px;
  margin: 4px auto 8px;
  padding: 0 4px;
  animation: suggestionsReveal 0.4s var(--ease-out) 0.15s both;
}

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

.follow-up-chip {
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 0.74rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  line-height: 1.4;
}

html.light .follow-up-chip {
  color: var(--violet-700);
  background: rgba(124, 58, 237, 0.04);
  border-color: rgba(124, 58, 237, 0.12);
}

.follow-up-chip:hover {
  background: var(--violet-950);
  border-color: var(--violet-600);
  color: var(--violet-300);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.1);
}

html.light .follow-up-chip:hover {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.3);
  color: var(--violet-800);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.08);
}

/* ---- Input area ---- */
.chat-input-area {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.chat-input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 180px;
  line-height: 1.5;
  transition: all 0.2s var(--ease-out);
}

.chat-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.chat-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--violet-glow);
  background: var(--bg-input-focus);
}

.btn-send {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--violet-600);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s var(--ease-out);
}

.btn-send:hover {
  background: var(--violet-500);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.btn-send svg {
  width: 18px;
  height: 18px;
}

.chat-input-hint {
  max-width: 800px;
  margin: 6px auto 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.5;
  text-align: center;
  letter-spacing: 0.02em;
}

/* ============================================
   MOBILE RESPONSIVE — All Pages
   ============================================ */

/* ---- Tablet (≤ 768px) ---- */
@media (max-width: 768px) {
  /* -- Chat sidebar -- */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .btn-sidebar-toggle {
    display: block;
  }

  /* -- Chat topbar -- */
  .topbar-nav-link span {
    display: none;
  }

  .topbar-nav-link {
    padding: 6px 8px;
  }

  .topbar-divider {
    display: none;
  }

  .btn-theme-toggle .theme-label-dark,
  .btn-theme-toggle .theme-label-light {
    display: none !important;
  }

  .btn-theme-toggle {
    padding: 7px 10px;
  }

  /* -- Chat messages -- */
  .chat-messages {
    padding: 14px 12px;
  }

  .chat-input-area {
    padding: 10px 12px 14px;
  }

  .chat-input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .message-user .message-content {
    max-width: 88%;
  }

  .message-assistant .message-content {
    padding: 10px 6px 10px 12px;
    font-size: 0.84rem;
  }

  .chat-welcome {
    padding: 32px 16px;
  }

  .chat-welcome h2 {
    font-size: 1.3rem;
  }

  .chat-welcome p {
    font-size: 0.8rem;
  }

  .chat-welcome-suggestions {
    gap: 6px;
    margin-top: 20px;
  }

  .suggestion-chip {
    padding: 7px 13px;
    font-size: 0.73rem;
  }

  /* -- Topbar -- */
  .chat-topbar {
    height: 48px;
    padding: 0 12px;
    gap: 8px;
  }

  .chat-topbar-model {
    font-size: 0.58rem;
    padding: 2px 8px;
  }

  .topbar-actions {
    gap: 4px;
  }

  /* -- Follow-up chips -- */
  .follow-up-suggestions {
    gap: 6px;
    padding: 0 2px;
  }

  .follow-up-chip {
    padding: 6px 12px;
    font-size: 0.72rem;
  }

  /* -- Admin header -- */
  .admin-header {
    padding: 14px 16px;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .admin-header-left {
    gap: 14px;
    flex-wrap: wrap;
  }

  .admin-title {
    font-size: 1.05rem;
  }

  /* -- Admin content -- */
  .admin-content {
    padding: 0 14px;
    margin: 20px auto;
  }

  /* -- Admin table: horizontal scroll -- */
  .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 0.78rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 12px;
  }

  /* -- Modal -- */
  .modal {
    margin: 16px;
    max-width: calc(100vw - 32px);
    padding: 24px 20px;
  }

  /* -- Integrations -- */
  .integration-card {
    padding: 20px 16px;
  }

  .integration-card-header {
    gap: 12px;
  }

  .integration-icon {
    width: 40px;
    height: 40px;
  }

  .integration-card-header h3 {
    font-size: 0.92rem;
  }

  .integration-card-header p {
    font-size: 0.78rem;
  }

  /* -- Login floating toggle -- */
  .login-theme-toggle {
    top: 16px;
    right: 16px;
  }

  /* -- Login background orbs — tablet -- */
  .login-shell::before {
    width: 400px;
    height: 400px;
    filter: blur(60px);
  }

  .login-shell::after {
    width: 320px;
    height: 320px;
    filter: blur(60px);
  }

  /* -- Chat welcome orbs — tablet -- */
  .chat-welcome::before {
    width: 320px;
    height: 320px;
    filter: blur(70px);
  }

  .chat-welcome::after {
    width: 260px;
    height: 260px;
    filter: blur(70px);
  }
}

/* ---- Small phone (≤ 480px) ---- */
@media (max-width: 480px) {
  /* -- Login — mobile glass card with animated border -- */
  .login-card {
    margin: 20px;
    padding: 40px 28px 34px;
    max-width: 100%;
    border: 2px solid transparent;
    border-radius: 18px;
    background:
      linear-gradient(#111113, #111113) padding-box,
      conic-gradient(
        from var(--border-angle),
        transparent 0%,
        rgba(139, 92, 246, 0.06) 4%,
        var(--violet-400) 10%,
        var(--violet-300) 15%,
        var(--violet-400) 20%,
        rgba(139, 92, 246, 0.06) 26%,
        transparent 32%,
        transparent 100%
      ) border-box;
    box-shadow:
      0 4px 24px rgba(0, 0, 0, 0.4),
      0 16px 48px rgba(0, 0, 0, 0.3),
      0 0 40px rgba(139, 92, 246, 0.06);
  }

  html.light .login-card {
    background:
      linear-gradient(#FFFFFF, #FFFFFF) padding-box,
      conic-gradient(
        from var(--border-angle),
        transparent 0%,
        rgba(124, 58, 237, 0.08) 4%,
        var(--violet-600) 10%,
        var(--violet-400) 15%,
        var(--violet-600) 20%,
        rgba(124, 58, 237, 0.08) 26%,
        transparent 32%,
        transparent 100%
      ) border-box;
    box-shadow:
      0 4px 24px rgba(0, 0, 0, 0.06),
      0 16px 48px rgba(0, 0, 0, 0.05),
      0 0 40px rgba(124, 58, 237, 0.04);
  }

  .login-brand {
    margin-bottom: 32px;
  }

  .login-brand-mark .brand-logo {
    height: 48px !important;
  }

  .login-brand-tagline {
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    margin-top: 12px;
  }

  .login-form {
    gap: 16px;
  }

  .form-input {
    padding: 14px 16px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(139, 92, 246, 0.08);
  }

  html.light .login-card .form-input {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.08);
  }

  .form-input:focus {
    background: rgba(0, 0, 0, 0.35);
    border-color: var(--border-focus);
  }

  html.light .login-card .form-input:focus {
    background: rgba(255, 255, 255, 0.8);
  }

  .btn-login {
    padding: 15px 24px;
    font-size: 0.90rem;
    border-radius: 10px;
    margin-top: 6px;
  }

  .login-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top-color: rgba(139, 92, 246, 0.06);
  }

  /* -- Login background orbs — phone -- */
  .login-shell::before {
    width: 280px;
    height: 280px;
    filter: blur(45px);
    top: -10%;
    left: -20%;
  }

  .login-shell::after {
    width: 220px;
    height: 220px;
    filter: blur(45px);
    bottom: -10%;
    right: -20%;
  }

  /* -- Chat welcome orbs — phone -- */
  .chat-welcome::before {
    width: 220px;
    height: 220px;
    filter: blur(50px);
  }

  .chat-welcome::after {
    width: 180px;
    height: 180px;
    filter: blur(50px);
  }

  /* -- Chat -- */
  .sidebar {
    width: 85vw;
    min-width: 260px;
    max-width: 320px;
  }

  .chat-messages {
    padding: 10px 8px;
    gap: 2px;
  }

  .chat-input-area {
    padding: 8px 10px 12px;
  }

  .chat-input-wrapper {
    gap: 8px;
  }

  .chat-input {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
  }

  .btn-send {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
  }

  .chat-input-hint {
    font-size: 0.55rem;
    margin-top: 4px;
  }

  .message {
    padding: 2px 0;
  }

  .message-user .message-content {
    padding: 9px 13px;
    font-size: 0.84rem;
    max-width: 92%;
  }

  .message-assistant .message-content {
    font-size: 0.83rem;
    padding: 8px 4px 8px 10px;
  }

  /* Tables in messages: scroll */
  .message-assistant .message-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 0.74rem;
  }

  .message-assistant .message-content pre {
    padding: 12px;
    font-size: 0.78rem;
    margin: 8px 0;
  }

  /* -- Admin -- */
  .admin-content {
    padding: 0 10px;
    margin: 14px auto;
  }

  .admin-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .btn-admin {
    padding: 8px 14px;
    font-size: 0.74rem;
  }

  /* -- Integrations -- */
  .integration-card {
    padding: 18px 14px;
  }

  .integration-card-header {
    flex-direction: column;
    gap: 10px;
  }

  .integration-form .form-input {
    font-size: 16px; /* prevents iOS zoom */
  }

  .connected-integration {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .connected-integration-info {
    gap: 10px;
  }

  /* -- Thinking dots mobile -- */
  .thinking-indicator {
    padding: 12px 4px;
    gap: 10px;
  }

  /* -- Tool indicator mobile -- */
  .tool-indicator {
    font-size: 0.65rem;
    padding: 6px 10px;
  }
}

/* ---- Safe area padding for notch devices ---- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-input-area {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  @media (max-width: 480px) {
    .chat-input-area {
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
  }
}

/* ============================================
   ADMIN PAGE
   ============================================ */

.admin-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-deep);
}

.admin-header {
  padding: 18px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.admin-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-primary);
}

.admin-title span {
  color: var(--violet-400);
}

html.light .admin-title span {
  color: var(--violet-600);
}

.admin-nav-link {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

.admin-nav-link:hover {
  color: var(--violet-400);
  border-bottom-color: var(--violet-400);
}

html.light .admin-nav-link:hover {
  color: var(--violet-600);
  border-bottom-color: var(--violet-600);
}

.admin-content {
  max-width: 900px;
  margin: 32px auto;
  padding: 0 32px;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-section-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-admin {
  padding: 8px 18px;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.btn-admin:hover {
  background: var(--violet-glow);
  border-color: var(--border-focus);
  color: var(--violet-400);
}

html.light .btn-admin:hover {
  color: var(--violet-600);
}

.btn-admin.primary {
  color: #fff;
  background: var(--violet-600);
  border-color: transparent;
}

.btn-admin.primary:hover {
  background: var(--violet-500);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.15);
}

.btn-admin.danger {
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.15);
}

html.light .btn-admin.danger {
  color: #DC2626;
}

.btn-admin.danger:hover {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.25);
}

/* User table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.admin-table th {
  text-align: left;
  padding: 11px 16px;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.admin-table td {
  padding: 11px 16px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--bg-card);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 20px;
  font-weight: 600;
}

.badge-admin {
  color: var(--violet-300);
  background: var(--violet-glow);
  border: 1px solid rgba(139, 92, 246, 0.15);
}

html.light .badge-admin {
  color: var(--violet-700);
}

.badge-employee {
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.badge-active { color: var(--violet-400); }
html.light .badge-active { color: var(--violet-600); }

.badge-inactive { color: #FCA5A5; }
html.light .badge-inactive { color: #DC2626; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: cardEnter 0.25s var(--ease-out) both;
}

.modal h3 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.modal .form-group {
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Admin responsive — see consolidated mobile section below */

/* ============================================
   INTEGRATIONS PAGE
   ============================================ */

.integration-status {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  margin-bottom: 24px;
  animation: msgFadeIn 0.25s var(--ease-out) both;
}

.integration-status.success {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: #6EE7B7;
}

html.light .integration-status.success {
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
}

.integration-status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #FCA5A5;
}

html.light .integration-status.error {
  background: rgba(239, 68, 68, 0.06);
  color: #DC2626;
}

.integrations-grid {
  margin-bottom: 24px;
}

.connected-integration {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: all 0.2s var(--ease-out);
}

.connected-integration:hover {
  border-color: var(--border-default);
}

.connected-integration-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.connected-integration-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.connected-integration-icon.wordpress {
  background: rgba(33, 150, 243, 0.12);
  color: #64B5F6;
}

.connected-integration-icon.google {
  background: rgba(234, 67, 53, 0.12);
  color: #EF9A9A;
}

.connected-integration-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.connected-integration-type {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.integration-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 16px;
}

.integration-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.integration-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.integration-icon.google {
  background: transparent;
  border: none;
}

.integration-card-header h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.integration-card-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.integration-form {
  display: grid;
  gap: 16px;
}

.integration-form .form-group {
  margin: 0;
}

.form-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

/* Integration connected state */
.integration-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.integration-badge.connected {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.integration-badge.disconnected {
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.integration-connected-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 12px;
}

.integration-connected-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.integration-connected-status svg {
  flex-shrink: 0;
}

.integration-icon.wordpress {
  background: rgba(33, 117, 155, 0.1);
  border-color: rgba(33, 117, 155, 0.2);
}

html.light .integration-icon.wordpress {
  background: rgba(33, 117, 155, 0.08);
}

/* ============================================
   Automations Page
   ============================================ */

.automation-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: -8px 0 24px;
  max-width: 600px;
}

.automation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.automation-card-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.automation-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.automation-card-info {
  flex: 1;
  min-width: 0;
}

.automation-card-info h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.automation-card-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Toggle switch */
.automation-toggle {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  cursor: pointer;
  margin-top: 2px;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 24px;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.25s ease, background 0.25s ease;
}

.toggle-input:checked + .toggle-slider {
  background: var(--violet-600);
  border-color: var(--violet-600);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: #fff;
}

/* Settings section */
.automation-card-settings {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  gap: 14px;
}

.automation-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.automation-card-settings select.form-input {
  appearance: none;
  background-image: 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='%23a1a1aa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Footer */
.automation-card-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.automation-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.automation-footer-right {
  display: flex;
  gap: 8px;
}

.automation-status-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.automation-status-badge.status-ok {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.automation-status-badge.status-warning {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.automation-status-badge.status-error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.automation-last-run {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.btn-logs {
  font-size: 0.75rem !important;
  padding: 6px 12px !important;
}

/* Logs modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Log entries */
.logs-list {
  display: grid;
  gap: 16px;
}

.log-entry {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.log-entry-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.log-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.log-email-sent {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--violet-400);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.log-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.log-details {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.log-detail-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.log-detail-item.severity-ok {
  border-left: 3px solid #22c55e;
}

.log-detail-item.severity-warning {
  border-left: 3px solid #f59e0b;
}

.log-detail-item.severity-error {
  border-left: 3px solid #ef4444;
}

.log-detail-check {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.72rem;
  white-space: nowrap;
  min-width: 120px;
}

.log-detail-msg {
  color: var(--text-muted);
  line-height: 1.4;
}

/* Integration status (shared with integrations page) */
.integration-status {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.integration-status.success {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.integration-status.error, .integration-status.warning {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.integration-status.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Automations mobile */
@media (max-width: 768px) {
  .automation-row {
    flex-direction: column;
    gap: 12px;
  }

  .automation-row .form-group {
    width: 100% !important;
  }

  .automation-card-top {
    flex-wrap: wrap;
  }

  .automation-card-info {
    flex-basis: calc(100% - 108px);
  }

  .automation-card-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .automation-footer-right {
    width: 100%;
  }

  .automation-footer-right .btn-admin {
    flex: 1;
  }

  .modal {
    max-height: 90vh;
  }

  .log-detail-item {
    flex-direction: column;
    gap: 2px;
  }

  .log-detail-check {
    min-width: unset;
  }
}

@media (max-width: 480px) {
  .automation-card {
    padding: 18px;
  }

  .automation-card-icon {
    width: 40px;
    height: 40px;
  }

  .automation-card-info h3 {
    font-size: 0.9rem;
  }

  .modal-body {
    padding: 16px;
  }
}

/* Dark/light theme transition animation */
html {
  transition: none;
}

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition: background 0.5s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, opacity 0.4s ease !important;
}
