/* ==========================================================================
   AIFUS Hub — Design System (Lucian UX/UI inspired semantic --ux-* tokens)
   ========================================================================== */

:root {
  /* Light Theme Tokens */
  --ux-bg: #f6f7fb;
  --ux-bg-elevated: #ffffff;
  --ux-surface: #ffffff;
  --ux-surface-2: #f1f3f9;
  --ux-surface-hover: #eef1f8;
  --ux-border: rgba(15, 23, 42, 0.08);
  --ux-border-strong: rgba(15, 23, 42, 0.14);

  --ux-text: #0f172a;
  --ux-text-secondary: #475569;
  --ux-text-muted: #64748b;

  --ux-accent: #4f46e5;
  --ux-accent-hover: #4338ca;
  --ux-accent-soft: rgba(79, 70, 229, 0.1);
  --ux-accent-ring: rgba(79, 70, 229, 0.25);

  --ux-cyan: #0284c7;
  --ux-cyan-soft: rgba(2, 132, 199, 0.1);

  --ux-success: #059669;
  --ux-success-soft: rgba(5, 150, 105, 0.11);

  --ux-warning: #d97706;
  --ux-warning-soft: rgba(217, 119, 6, 0.12);

  --ux-danger: #dc2626;
  --ux-danger-soft: rgba(220, 38, 38, 0.1);

  --ux-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --ux-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --ux-shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --ux-shadow-lg: 0 22px 60px rgba(15, 23, 42, 0.16), 0 4px 14px rgba(15, 23, 42, 0.06);

  --ux-radius-sm: 8px;
  --ux-radius-md: 12px;
  --ux-radius-lg: 16px;
  --ux-radius-xl: 20px;
  --ux-radius-full: 999px;

  --ux-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ux-sidebar-w: 268px;
  --ux-topbar-h: 68px;
  --ux-bottom-nav-h: 66px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

[data-theme="dark"] {
  --ux-bg: #0b0e14;
  --ux-bg-elevated: #111622;
  --ux-surface: #131926;
  --ux-surface-2: #1a2233;
  --ux-surface-hover: #212b40;
  --ux-border: rgba(255, 255, 255, 0.08);
  --ux-border-strong: rgba(255, 255, 255, 0.15);

  --ux-text: #f1f5f9;
  --ux-text-secondary: #cbd5e1;
  --ux-text-muted: #94a3b8;

  --ux-accent: #6366f1;
  --ux-accent-hover: #818cf8;
  --ux-accent-soft: rgba(99, 102, 241, 0.16);
  --ux-accent-ring: rgba(99, 102, 241, 0.35);

  --ux-cyan: #38bdf8;
  --ux-cyan-soft: rgba(56, 189, 248, 0.15);

  --ux-success: #34d399;
  --ux-success-soft: rgba(52, 211, 153, 0.15);

  --ux-warning: #fbbf24;
  --ux-warning-soft: rgba(251, 191, 36, 0.16);

  --ux-danger: #f87171;
  --ux-danger-soft: rgba(248, 113, 113, 0.16);

  --ux-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --ux-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --ux-shadow-md: 0 14px 32px rgba(0, 0, 0, 0.45);
  --ux-shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.65);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--ux-bg);
  color: var(--ux-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s var(--ux-ease), color 0.25s var(--ux-ease);
}

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

button {
  cursor: pointer;
}

a {
  color: var(--ux-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--ux-border-strong);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ux-text-muted);
}

/* Icons */
.icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.icon-slot svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.icon-slot.sm {
  width: 15px;
  height: 15px;
}
.icon-slot.muted {
  color: var(--ux-text-muted);
}

/* ==========================================================================
   App Shell Layout
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--ux-sidebar-w);
  flex-shrink: 0;
  background: var(--ux-bg-elevated);
  border-right: 1px solid var(--ux-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  transition: background-color 0.25s var(--ux-ease), border-color 0.25s var(--ux-ease);
}

.sidebar-header {
  padding: 18px 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: var(--ux-radius-md);
  text-align: left;
  width: 100%;
  transition: background 0.18s var(--ux-ease);
}
.brand:hover {
  background: var(--ux-surface-2);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(79, 70, 229, 0.28));
}
.brand-mark.sm {
  width: 30px;
  height: 30px;
}
.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--ux-text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.sidebar-search-wrap {
  padding: 4px 14px 12px;
}

.cmd-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border);
  background: var(--ux-surface-2);
  color: var(--ux-text-muted);
  font-size: 13px;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.cmd-trigger:hover {
  border-color: var(--ux-border-strong);
  background: var(--ux-surface-hover);
  color: var(--ux-text-secondary);
}
.cmd-trigger-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbd-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--ux-bg-elevated);
  border: 1px solid var(--ux-border-strong);
  color: var(--ux-text-muted);
}

.sidebar-nav {
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ux-text-muted);
  padding: 8px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--ux-radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ux-text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: all 0.18s var(--ux-ease);
  position: relative;
}
.nav-item:hover {
  background: var(--ux-surface-2);
  color: var(--ux-text);
}
.nav-item.active {
  background: var(--ux-accent-soft);
  color: var(--ux-accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ux-accent);
}

.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--ux-radius-full);
  background: var(--ux-surface-2);
  color: var(--ux-text-muted);
}
.nav-badge.accent {
  background: var(--ux-accent-soft);
  color: var(--ux-accent);
}
.nav-badge.live {
  background: var(--ux-success-soft);
  color: var(--ux-success);
}

.sidebar-section {
  padding: 10px 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-quick-rooms {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.quick-room-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--ux-radius-sm);
  border: none;
  background: transparent;
  color: var(--ux-text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.16s, color 0.16s;
}
.quick-room-btn:hover {
  background: var(--ux-surface-2);
  color: var(--ux-text);
}
.room-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ux-success);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--ux-success-soft);
}
.room-dot.upcoming {
  background: var(--ux-warning);
  box-shadow: 0 0 0 3px var(--ux-warning-soft);
}
.quick-room-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--ux-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-user-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--ux-radius-md);
  cursor: pointer;
  transition: background 0.16s;
}
.current-user-card:hover {
  background: var(--ux-surface-2);
}
.user-meta {
  min-width: 0;
  flex: 1;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--ux-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-actions {
  display: flex;
  gap: 4px;
}

/* Main Wrap & Topbar */
.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--ux-topbar-h);
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--ux-bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ux-border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mobile-brand {
  display: none;
  cursor: pointer;
}

.page-heading {
  min-width: 0;
}
.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ux-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

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

.mobile-only {
  display: none !important;
}

.content-area {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  animation: fadeSlideIn 0.28s var(--ux-ease);
}

.content-area.chat-mode {
  padding: 18px 24px 20px;
  max-width: 100%;
  height: calc(100vh - var(--ux-topbar-h));
  display: flex;
  flex-direction: column;
}

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

/* ==========================================================================
   Core UI Primitives (Buttons, Badges, Cards, Avatars, Inputs)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8.5px 14px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-surface);
  color: var(--ux-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: all 0.16s var(--ux-ease);
  white-space: nowrap;
}
.btn:hover {
  background: var(--ux-surface-2);
  border-color: var(--ux-text-muted);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn-primary {
  background: var(--ux-accent);
  border-color: var(--ux-accent);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--ux-accent-hover);
  border-color: var(--ux-accent-hover);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.34);
}
.btn-soft {
  background: var(--ux-accent-soft);
  border-color: transparent;
  color: var(--ux-accent);
}
.btn-soft:hover {
  background: color-mix(in srgb, var(--ux-accent) 18%, transparent);
  border-color: transparent;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ux-text-secondary);
}
.btn-ghost:hover {
  background: var(--ux-surface-2);
  border-color: transparent;
  color: var(--ux-text);
}
.btn-danger-soft {
  background: var(--ux-danger-soft);
  border-color: transparent;
  color: var(--ux-danger);
}
.btn-danger-soft:hover {
  background: color-mix(in srgb, var(--ux-danger) 20%, transparent);
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--ux-radius-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border);
  background: var(--ux-surface);
  color: var(--ux-text-secondary);
  transition: all 0.16s var(--ux-ease);
}
.icon-btn:hover {
  background: var(--ux-surface-2);
  color: var(--ux-text);
  border-color: var(--ux-border-strong);
}

.card {
  background: var(--ux-surface);
  border: 1px solid var(--ux-border);
  border-radius: var(--ux-radius-lg);
  padding: 20px;
  box-shadow: var(--ux-shadow-xs);
  transition: border-color 0.2s var(--ux-ease), box-shadow 0.2s var(--ux-ease), transform 0.2s var(--ux-ease);
}
.card-interactive:hover {
  border-color: color-mix(in srgb, var(--ux-accent) 38%, var(--ux-border));
  box-shadow: var(--ux-shadow-sm);
  transform: translateY(-2px);
}

/* Avatars */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  user-select: none;
}
.avatar.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 11px;
}
.avatar.xs {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 10px;
}
.avatar.lg {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 19px;
}

.avatar-stack {
  display: flex;
  align-items: center;
}
.avatar-stack .avatar {
  border: 2px solid var(--ux-surface);
  margin-left: -8px;
}
.avatar-stack .avatar:first-child {
  margin-left: 0;
}

/* Badges & Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3.5px 9px;
  border-radius: var(--ux-radius-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.pill-neutral {
  background: var(--ux-surface-2);
  color: var(--ux-text-secondary);
}
.pill-accent {
  background: var(--ux-accent-soft);
  color: var(--ux-accent);
}
.pill-success {
  background: var(--ux-success-soft);
  color: var(--ux-success);
}
.pill-warning {
  background: var(--ux-warning-soft);
  color: var(--ux-warning);
}
.pill-danger {
  background: var(--ux-danger-soft);
  color: var(--ux-danger);
}
.pill-cyan {
  background: var(--ux-cyan-soft);
  color: var(--ux-cyan);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseGlow 1.8s infinite;
}
@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* Filter Toolbar & Segmented Tabs */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.segmented {
  display: inline-flex;
  background: var(--ux-surface-2);
  padding: 4px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border);
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--ux-text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.16s var(--ux-ease);
}
.seg-btn:hover {
  color: var(--ux-text);
}
.seg-btn.active {
  background: var(--ux-surface);
  color: var(--ux-text);
  box-shadow: var(--ux-shadow-xs);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
  flex: 1;
  max-width: 360px;
}
.search-box .icon-slot {
  position: absolute;
  left: 11px;
  color: var(--ux-text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 8.5px 12px 8.5px 36px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-surface);
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.search-box input:focus {
  border-color: var(--ux-accent);
  box-shadow: 0 0 0 3px var(--ux-accent-ring);
}

/* ==========================================================================
   Dashboard View
   ========================================================================== */

.hero-banner {
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 55%, #0284c7 100%);
  border-radius: var(--ux-radius-xl);
  padding: 24px 28px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(79, 70, 229, 0.24);
}
.hero-banner::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.hero-banner h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-banner p {
  margin: 0;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.88);
  max-width: 600px;
  line-height: 1.5;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.btn-hero {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  backdrop-filter: blur(8px);
}
.btn-hero:hover {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.45);
}
.btn-hero-solid {
  background: #fff;
  border-color: #fff;
  color: #312e81;
}
.btn-hero-solid:hover {
  background: #eef2ff;
  border-color: #eef2ff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
}
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ux-text-muted);
}
.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.kpi-sub {
  font-size: 12px;
  color: var(--ux-text-muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-comp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border);
  background: var(--ux-bg);
  transition: border-color 0.16s, background 0.16s;
}
.mini-comp-row:hover {
  border-color: color-mix(in srgb, var(--ux-accent) 40%, var(--ux-border));
  background: var(--ux-surface-2);
}

.mini-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--ux-radius-md);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.mini-member-row:hover {
  background: var(--ux-surface-2);
  border-color: var(--ux-border);
}

/* ==========================================================================
   Members Grid & Registration Info
   ========================================================================== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.member-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
}
.member-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.member-card-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.member-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  margin: 0;
}
.member-role {
  font-size: 12.5px;
  color: var(--ux-text-muted);
  margin-top: 2px;
}

.reg-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--ux-radius-md);
  background: var(--ux-bg);
  border: 1px solid var(--ux-border);
  font-size: 12px;
}
.reg-mini-item {
  min-width: 0;
}
.reg-mini-label {
  font-size: 10.5px;
  color: var(--ux-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.reg-mini-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-chip {
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--ux-surface-2);
  color: var(--ux-text-secondary);
}

.card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--ux-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ==========================================================================
   Competitions Grid
   ========================================================================== */

.comp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}

.comp-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comp-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 12.5px;
  color: var(--ux-text-secondary);
}
.comp-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.comp-meta-item span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  height: 6px;
  border-radius: 99px;
  background: var(--ux-surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--ux-accent), var(--ux-cyan));
  transition: width 0.35s var(--ux-ease);
}

/* ==========================================================================
   Docs Repository
   ========================================================================== */

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.doc-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.doc-type-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==========================================================================
   Internal Hackathon Chat
   ========================================================================== */

.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  background: var(--ux-surface);
  border: 1px solid var(--ux-border);
  border-radius: var(--ux-radius-xl);
  overflow: hidden;
  box-shadow: var(--ux-shadow-sm);
}

.chat-channels {
  border-right: 1px solid var(--ux-border);
  background: var(--ux-bg-elevated);
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-channels-head {
  padding: 16px;
  border-bottom: 1px solid var(--ux-border);
}
.chat-channels-head h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
}
.chat-channels-head p {
  margin: 0;
  font-size: 11.5px;
  color: var(--ux-text-muted);
}

.channel-list {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 10px 11px;
  border-radius: var(--ux-radius-md);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  overflow: hidden;
  transition: all 0.15s;
}
.channel-item:hover {
  background: var(--ux-surface-2);
}
.channel-item.active {
  background: var(--ux-accent-soft);
  border-color: color-mix(in srgb, var(--ux-accent) 24%, transparent);
}
.channel-hash {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--ux-surface-2);
  color: var(--ux-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.channel-item.active .channel-hash {
  background: var(--ux-accent);
  color: #fff;
}
.channel-info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.channel-name {
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-preview {
  display: block;
  max-width: 100%;
  font-size: 11.5px;
  color: var(--ux-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--ux-surface);
}

.chat-room-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--ux-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}
.chat-room-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.chat-back-btn {
  display: none;
}

.chat-pin-bar {
  padding: 8px 18px;
  background: var(--ux-accent-soft);
  border-bottom: 1px solid var(--ux-border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ux-accent);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.chat-pin-bar span:last-child {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-messages {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  max-width: min(82%, 100%);
}
.msg-row.own {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.msg-row.own .msg-body {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
}
.msg-sender {
  font-weight: 600;
  color: var(--ux-text);
}
.msg-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ux-text-muted);
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  background: var(--ux-surface-2);
  color: var(--ux-text);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-row.own .msg-bubble {
  background: var(--ux-accent);
  color: #fff;
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}

.msg-code {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 12px;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
}

.msg-doc-card {
  margin-top: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
}
.msg-row:not(.own) .msg-doc-card {
  background: var(--ux-surface);
  border-color: var(--ux-border-strong);
  color: var(--ux-text);
}

.chat-composer {
  padding: 12px 16px;
  border-top: 1px solid var(--ux-border);
  background: var(--ux-bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  padding: 10px 13px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-surface);
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
}
.composer-input:focus {
  border-color: var(--ux-accent);
  box-shadow: 0 0 0 3px var(--ux-accent-ring);
}

.persona-select {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-surface);
  font-size: 12px;
  font-weight: 500;
  outline: none;
}

/* ==========================================================================
   Modals, Forms & Command Palette
   ========================================================================== */

.modal-backdrop, .cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.16s ease;
}
.modal-backdrop.open, .cmd-backdrop.open {
  display: flex;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  background: var(--ux-surface);
  border: 1px solid var(--ux-border-strong);
  border-radius: var(--ux-radius-xl);
  box-shadow: var(--ux-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.22s var(--ux-ease);
}
.modal-dialog.wide {
  max-width: 820px;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--ux-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--ux-border);
  background: var(--ux-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Form Elements */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group.full {
  grid-column: 1 / -1;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ux-text-secondary);
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-bg);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.form-control:focus {
  border-color: var(--ux-accent);
  box-shadow: 0 0 0 3px var(--ux-accent-ring);
}

/* Info Copy Rows in Profile Modal */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.info-box {
  padding: 10px 12px;
  border-radius: var(--ux-radius-md);
  background: var(--ux-bg);
  border: 1px solid var(--ux-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.info-box-content {
  min-width: 0;
}
.info-box-label {
  font-size: 11px;
  color: var(--ux-text-muted);
}
.info-box-val {
  font-size: 13px;
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
}
.info-box-val.mono {
  font-family: var(--font-mono);
}

/* Export Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--ux-border);
  border-radius: var(--ux-radius-md);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--ux-border);
  white-space: nowrap;
}
.data-table th {
  background: var(--ux-surface-2);
  font-weight: 600;
  color: var(--ux-text-secondary);
}
.data-table tr:last-child td {
  border-bottom: none;
}

/* Checklist */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--ux-radius-sm);
  border: 1px solid var(--ux-border);
  background: var(--ux-bg);
  cursor: pointer;
  font-size: 13px;
}
.checklist-item.done {
  opacity: 0.68;
  text-decoration: line-through;
}

/* Command Palette */
.cmd-panel {
  width: 100%;
  max-width: 560px;
  background: var(--ux-surface);
  border: 1px solid var(--ux-border-strong);
  border-radius: var(--ux-radius-xl);
  box-shadow: var(--ux-shadow-lg);
  overflow: hidden;
  align-self: flex-start;
  margin-top: 10vh;
}
.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ux-border);
}
.cmd-input-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14.5px;
  outline: none;
}
.cmd-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--ux-radius-md);
  text-align: left;
  font-size: 13.5px;
}
.cmd-item:hover {
  background: var(--ux-surface-2);
}

/* Toast Notifications */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: var(--ux-radius-md);
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--ux-shadow-md);
  animation: toastIn 0.24s var(--ux-ease);
}
[data-theme="dark"] .toast {
  background: #f8fafc;
  color: #0f172a;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Floating Mini AI Chatbot Widget
   ========================================================================== */

.bot-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 85;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.bot-fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px 0 14px;
  border-radius: var(--ux-radius-full);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 60%, #0284c7 100%);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(79, 70, 229, 0.38), 0 2px 6px rgba(15, 23, 42, 0.14);
  transition: transform 0.2s var(--ux-ease), box-shadow 0.2s var(--ux-ease);
}
.bot-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(79, 70, 229, 0.48), 0 4px 10px rgba(15, 23, 42, 0.18);
}
.bot-fab-icon {
  display: inline-flex;
  width: 19px;
  height: 19px;
}
.bot-fab-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.bot-panel {
  width: 396px;
  max-width: calc(100vw - 28px);
  height: 560px;
  max-height: calc(100dvh - 108px);
  background: var(--ux-surface);
  border: 1px solid var(--ux-border-strong);
  border-radius: var(--ux-radius-xl);
  box-shadow: var(--ux-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.22s var(--ux-ease);
}
.bot-panel.open {
  display: flex;
}

.bot-header {
  padding: 13px 14px;
  border-bottom: 1px solid var(--ux-border);
  background: var(--ux-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bot-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.bot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bot-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}
.bot-status {
  font-size: 11px;
  color: var(--ux-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.bot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.bot-hdr-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.bot-config {
  padding: 13px 14px;
  background: var(--ux-bg);
  border-bottom: 1px solid var(--ux-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}
.bot-config[hidden] {
  display: none;
}
.bot-config-title {
  font-size: 12.5px;
  font-weight: 700;
}
.bot-config-desc {
  font-size: 11.5px;
  color: var(--ux-text-muted);
  line-height: 1.45;
}
.bot-config-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bot-config-links {
  font-size: 11.5px;
  color: var(--ux-text-secondary);
  line-height: 1.45;
}
.bot-config-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.bot-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 88%;
}
.bot-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.bot-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.bot-bubble {
  padding: 9.5px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.bot-msg.assistant .bot-bubble {
  background: var(--ux-surface-2);
  color: var(--ux-text);
  border-top-left-radius: 4px;
}
.bot-msg.user .bot-bubble {
  background: var(--ux-accent);
  color: #fff;
  border-top-right-radius: 4px;
}
.bot-source-tag {
  font-size: 10.5px;
  color: var(--ux-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.bot-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
}
.bot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ux-text-muted);
  animation: botBounce 1.1s infinite ease-in-out;
}
.bot-typing span:nth-child(2) { animation-delay: 0.16s; }
.bot-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes botBounce {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

.bot-suggestions {
  padding: 8px 12px 6px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--ux-border);
  background: var(--ux-bg-elevated);
}
.bot-suggestions::-webkit-scrollbar {
  display: none;
}
.bot-chip {
  flex-shrink: 0;
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-surface);
  color: var(--ux-text-secondary);
  padding: 5px 10px;
  border-radius: var(--ux-radius-full);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}
.bot-chip:hover {
  border-color: var(--ux-accent);
  color: var(--ux-accent);
  background: var(--ux-accent-soft);
}

.bot-composer {
  padding: 10px 12px;
  background: var(--ux-bg-elevated);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bot-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--ux-radius-md);
  border: 1px solid var(--ux-border-strong);
  background: var(--ux-surface);
  font-size: 13px;
  outline: none;
}
.bot-input:focus {
  border-color: var(--ux-accent);
  box-shadow: 0 0 0 3px var(--ux-accent-ring);
}
.bot-send-btn {
  height: 38px;
  width: 38px;
  padding: 0;
  flex-shrink: 0;
}

/* Overflow & Wrap Safety Helpers */
html, body, .app-shell, .main-wrap {
  overflow-x: clip;
}
.segmented {
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar {
  display: none;
}
.doc-toolbar-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}
.doc-comp-select {
  width: auto;
  min-width: 210px;
  max-width: 100%;
  padding: 7.5px 12px;
  font-size: 13px;
}
.mini-comp-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.composer-tools-left,
.composer-tools-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.persona-select {
  max-width: 210px;
  min-width: 0;
  text-overflow: ellipsis;
}

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints (Desktop -> Laptop -> Tablet -> Mobile -> Small Mobile)
   ========================================================================== */

@media (max-width: 1180px) {
  :root {
    --ux-sidebar-w: 244px;
  }
  .topbar {
    padding: 0 20px;
  }
  .content-area {
    padding: 20px 20px 36px;
  }
  .chat-layout {
    grid-template-columns: 248px minmax(0, 1fr);
  }
}

@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .comp-grid {
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  }
}

@media (max-width: 820px) {
  .sidebar {
    display: none;
  }
  .mobile-brand {
    display: inline-flex;
  }
  .mobile-only {
    display: inline-flex !important;
  }
  .topbar {
    padding: 0 12px;
    height: 58px;
    gap: 8px;
  }
  .page-title {
    font-size: 15.5px;
  }
  .page-subtitle {
    display: none;
  }
  .topbar-actions {
    gap: 6px;
  }
  .topbar-actions .btn {
    padding: 7px 10px;
    font-size: 12px;
  }
  .topbar-actions .pill {
    font-size: 11px;
    padding: 4px 8px;
  }

  .content-area {
    padding: 14px 12px calc(var(--ux-bottom-nav-h) + 86px);
  }
  .content-area.chat-mode {
    padding: 10px 10px calc(var(--ux-bottom-nav-h) + 10px);
    height: calc(100dvh - 58px);
  }

  .hero-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
    gap: 14px;
    margin-bottom: 16px;
  }
  .hero-banner h2 {
    font-size: 18px;
  }
  .hero-banner p {
    font-size: 13px;
  }
  .hero-actions {
    width: 100%;
  }

  .kpi-grid {
    gap: 10px;
    margin-bottom: 16px;
  }
  .card {
    padding: 15px;
    border-radius: var(--ux-radius-md);
  }
  .kpi-value {
    font-size: 23px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .doc-toolbar-left {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .doc-comp-select {
    width: 100%;
    min-width: 0;
  }
  .segmented {
    width: 100%;
  }
  .search-box {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .comp-grid, .cards-grid, .docs-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .form-grid, .info-grid {
    grid-template-columns: 1fr;
  }

  /* Mobile Chat Slide Switch */
  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
    border-radius: var(--ux-radius-lg);
  }
  .chat-channels {
    border-right: none;
  }
  .chat-layout[data-mobile-view="channels"] .chat-main {
    display: none;
  }
  .chat-layout[data-mobile-view="room"] .chat-channels {
    display: none;
  }
  .chat-back-btn {
    display: inline-flex;
  }
  .chat-room-header {
    padding: 11px 12px;
  }
  .chat-pin-bar {
    padding: 7px 12px;
  }
  .chat-messages {
    padding: 12px;
  }
  .msg-row {
    max-width: 94%;
  }
  .chat-composer {
    padding: 10px 10px;
  }
  .composer-tools {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .composer-tools-left {
    width: 100%;
  }
  .composer-tools-left .persona-select {
    flex: 1;
    max-width: none;
  }
  .composer-tools-right {
    width: 100%;
    justify-content: space-between;
  }
  .composer-tools-right .persona-select {
    flex: 1;
    max-width: none;
  }

  /* Bottom Navigation Bar */
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--ux-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--ux-bg-elevated) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--ux-border);
    z-index: 50;
  }
  .bottom-nav-item {
    border: none;
    background: transparent;
    color: var(--ux-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    position: relative;
    padding: 4px 2px;
  }
  .bottom-nav-item.active {
    color: var(--ux-accent);
  }
  .bottom-dot {
    position: absolute;
    top: 9px;
    right: calc(50% - 14px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ux-success);
  }

  /* Floating Mini Bot positioned cleanly above Bottom Nav */
  .bot-widget {
    right: 12px;
    bottom: calc(var(--ux-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  }
  .content-area.chat-mode ~ .bottom-nav,
  body[data-view="chat"] .bot-widget {
    /* In chat view on mobile, keep FAB compact at top-right or lower corner without blocking composer */
    bottom: calc(var(--ux-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 74px);
  }
  .bot-fab {
    height: 44px;
    padding: 0 14px 0 12px;
    font-size: 12.5px;
  }

  .toast-stack {
    bottom: calc(var(--ux-bottom-nav-h) + 14px);
    left: 12px;
    right: 12px;
  }
}

/* Native-feeling Mobile Bottom Sheet Modals & Compact Rows */
@media (max-width: 640px) {
  .mini-comp-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 13px;
  }
  .mini-comp-actions {
    width: 100%;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px dashed var(--ux-border);
  }

  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal-dialog,
  .modal-dialog.wide {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
  .modal-header {
    padding: 14px 16px;
  }
  .modal-title {
    font-size: 15.5px;
  }
  .modal-body {
    padding: 15px 16px;
  }
  .modal-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .modal-footer .btn {
    flex: 1;
    min-width: 110px;
  }

  .cmd-backdrop {
    padding: 12px;
  }
  .cmd-panel {
    margin-top: 4vh;
  }

  /* Mini Bot Panel turns into full bottom sheet on small screens */
  .bot-panel.open {
    position: fixed;
    inset: 10px 10px calc(var(--ux-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 10px) 10px;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    z-index: 95;
  }
}

/* Extra-small phones (<= 460px) */
@media (max-width: 460px) {
  .topbar-actions .btn-secondary-mobile-hide {
    display: none;
  }
  .topbar-actions .btn span:not(.icon-slot) {
    font-size: 11.5px;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .kpi-card {
    padding: 12px;
    gap: 6px;
  }
  .kpi-label {
    font-size: 11.5px;
  }
  .kpi-icon {
    width: 30px;
    height: 30px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .kpi-sub {
    font-size: 11px;
  }
  .comp-meta-grid,
  .reg-mini-grid {
    grid-template-columns: 1fr;
  }
  .card-foot {
    flex-wrap: wrap;
    gap: 8px;
  }
  .bot-fab-label {
    display: none;
  }
  .bot-fab {
    width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
  }
}

/* ==========================================================================
   Visual Polish, Ambient Depth & 60fps Micro-Interactions (Lucian UX/UI)
   ========================================================================== */

/* Subtle Ambient Mesh Backdrop */
body {
  background-image:
    radial-gradient(620px circle at 12% -6%, rgba(79, 70, 229, 0.08), transparent 58%),
    radial-gradient(540px circle at 92% 8%, rgba(14, 165, 233, 0.07), transparent 56%);
  background-attachment: fixed;
}
[data-theme="dark"] body {
  background-image:
    radial-gradient(680px circle at 16% -8%, rgba(99, 102, 241, 0.14), transparent 58%),
    radial-gradient(580px circle at 90% 10%, rgba(56, 189, 248, 0.1), transparent 56%);
}

/* Brand Mark Hover Glow */
.brand:hover .brand-mark {
  transform: scale(1.06) rotate(-2deg);
  filter: drop-shadow(0 6px 14px rgba(79, 70, 229, 0.42));
}
.brand-mark {
  transition: transform 0.28s var(--ux-ease), filter 0.28s var(--ux-ease);
}

/* Hero Banner Animated Aurora Mesh */
.hero-banner {
  background: linear-gradient(125deg, #4338ca 0%, #4f46e5 32%, #2563eb 66%, #0284c7 100%);
  background-size: 180% 180%;
  animation: heroAurora 14s ease-in-out infinite alternate;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.hero-banner::before {
  content: '';
  position: absolute;
  left: -40px;
  bottom: -90px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.32) 0%, transparent 70%);
  pointer-events: none;
}
@keyframes heroAurora {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* Primary Button Diagonal Sheen Sweep & Tactile Press */
.btn-primary {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.24) 50%, transparent 75%);
  transform: translateX(-130%);
  transition: transform 0.55s var(--ux-ease);
  pointer-events: none;
}
.btn-primary:hover::after {
  transform: translateX(130%);
}
.btn:active,
.icon-btn:active,
.bot-chip:active,
.seg-btn:active {
  transform: scale(0.97);
}

/* Copy Success Flash State */
.btn.copied-flash,
.icon-btn.copied-flash {
  background: var(--ux-success-soft) !important;
  color: var(--ux-success) !important;
  border-color: color-mix(in srgb, var(--ux-success) 45%, transparent) !important;
}

/* Pointer Spotlight Hover Glow on Interactive Cards (Desktop hover-capable devices only) */
@media (hover: hover) and (pointer: fine) {
  .card-interactive {
    position: relative;
    overflow: hidden;
  }
  .card-interactive::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
      340px circle at var(--mx, 50%) var(--my, 50%),
      rgba(79, 70, 229, 0.085),
      transparent 65%
    );
    opacity: 0;
    transition: opacity 0.25s var(--ux-ease);
    pointer-events: none;
    z-index: 0;
  }
  [data-theme="dark"] .card-interactive::before {
    background: radial-gradient(
      340px circle at var(--mx, 50%) var(--my, 50%),
      rgba(99, 102, 241, 0.15),
      transparent 65%
    );
  }
  .card-interactive:hover::before {
    opacity: 1;
  }
  .card-interactive > * {
    position: relative;
    z-index: 1;
  }
}

/* KPI Icon Micro-lift */
.kpi-card:hover .kpi-icon {
  transform: scale(1.08) translateY(-1px);
}
.kpi-icon {
  transition: transform 0.24s var(--ux-ease);
}

/* Staggered Card Entrance Animation */
.ux-stagger {
  animation: uxCardEnter 0.36s var(--ux-ease) both;
  animation-delay: calc(var(--stagger-i, 0) * 38ms);
}
@keyframes uxCardEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Progress Bar Animated Sheen */
.progress-fill {
  position: relative;
  overflow: hidden;
}
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: progressShimmer 2.6s infinite ease-in-out;
}
@keyframes progressShimmer {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(120%); }
}

/* Chat Message Pop-In & Avatar Hover */
.msg-row,
.bot-msg {
  animation: msgPopIn 0.24s var(--ux-ease) both;
}
@keyframes msgPopIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avatar-stack .avatar {
  transition: transform 0.2s var(--ux-ease);
}
.avatar-stack .avatar:hover {
  transform: translateY(-3px) scale(1.08);
  z-index: 4;
}

/* Floating Bot FAB Breathing Aura */
.bot-fab {
  position: relative;
}
.bot-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.45), rgba(14, 165, 233, 0.45));
  z-index: -1;
  opacity: 0.45;
  filter: blur(8px);
  animation: fabBreathe 3.2s ease-in-out infinite;
}
@keyframes fabBreathe {
  0%, 100% { opacity: 0.32; transform: scale(0.98); }
  50% { opacity: 0.65; transform: scale(1.04); }
}

/* Focus-Visible Accessibility Ring */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ux-accent);
  outline-offset: 2px;
}

/* Strict Reduced-Motion Safeguard */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Security & Privacy Shield Styles
   ========================================================================== */

body {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, select, pre, code, .msg-bubble, .bot-bubble, .info-box-val {
  -webkit-user-select: text;
  user-select: text;
}

.bot-session-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ux-text-secondary);
  cursor: pointer;
}
.bot-session-check input {
  accent-color: var(--ux-accent);
  width: 15px;
  height: 15px;
}

.pin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--ux-radius-md);
  background: var(--ux-warning-soft);
  border: 1px solid color-mix(in srgb, var(--ux-warning) 30%, transparent);
  color: var(--ux-text);
  font-size: 12.5px;
}
.pin-banner.unlocked {
  background: var(--ux-success-soft);
  border-color: color-mix(in srgb, var(--ux-success) 30%, transparent);
}

.privacy-shield {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(11, 14, 20, 0.86);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.privacy-shield.active {
  display: flex;
}
.privacy-shield-card {
  width: 100%;
  max-width: 440px;
  background: var(--ux-surface);
  border: 1px solid var(--ux-border-strong);
  border-radius: var(--ux-radius-xl);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--ux-shadow-lg);
}
.privacy-shield-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--ux-accent-soft);
  color: var(--ux-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.privacy-shield-icon svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.privacy-shield-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}
.privacy-shield-card p {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--ux-text-muted);
  line-height: 1.55;
}
.privacy-shield-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
