/* ============================================================================
   aiia Smart Canvas — Shell Stylesheet (Dark Theme)
   ============================================================================
   Shell layout: header, canvas area, input bar, drawer, animations.
   Content component styles live in design-system.css.
   ========================================================================= */

/* ----- Tokens ---------------------------------------------------------- */
:root {
  --aiia-blue: #2B8FE8;
  --aiia-orange: #FF5E54;
  --aiia-black: #282828;
  --aiia-green: #2BBF5D;
  --aiia-purple: #7B61FF;

  --bg: #0a0a0a;
  --bg-signal: #282828;
  --text: #FFFFFF;
  --text-cream: #F8F3EC;
  --text-secondary: rgba(255,255,255,0.6);
  --text-muted: rgba(255,255,255,0.5);
  --text-subtle: rgba(255,255,255,0.35);
  --border: rgba(255,255,255,0.1);

  --radius: 12px;
  --radius-lg: 16px;
  --space: 8px;

  --focus-glow: 0 0 0 2px rgba(18,131,235,0.15), 0 0 12px rgba(18,131,235,0.08);
  --input-shadow: 0 4px 24px rgba(0,0,0,0.3);

  /* Fluid type scale */
  --type-hero: clamp(36px, 5vw, 56px);
  --type-greeting: clamp(20px, 3vw, 28px);
  --type-body: clamp(13px, 1.5vw, 15px);
  --type-label: clamp(11px, 1.2vw, 13px);

  /* Fluid spacing */
  --space-canvas: clamp(8px, 2vw, 40px);
  --space-input: clamp(8px, 3vw, 100px);
}

/* ----- Reset & Base ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
*:focus-visible { outline: 2px solid var(--aiia-blue); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--aiia-blue); outline-offset: 2px; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(160deg, #0a0a0a 0%, #1A0F2E 40%, #0D1A2E 70%, #0a0a0a 100%);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.sr-only:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto;
  padding: 8px 16px; margin: 0; overflow: visible; clip: auto;
  white-space: normal; z-index: 9999;
  background: var(--aiia-blue); color: #fff;
  border-radius: 4px; font-size: 14px; font-weight: 500;
  outline: 2px solid #fff; outline-offset: 2px;
}

/* ----- Header ---------------------------------------------------------- */
.aiia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.aiia-logo { display: block; }
.aiia-logo svg { height: 24px; fill: #FFFFFF; }

.aiia-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.aiia-header__user-name {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}
.aiia-header__sep {
  color: rgba(255,255,255,0.3);
  font-size: 12px;
}
.aiia-header__user-role {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
}

.aiia-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

#aiia-user-name {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  user-select: none;
}

.aiia-user-info__sep {
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  user-select: none;
}

.aiia-user-role {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
  user-select: none;
}

/* Switch User menu */
.aiia-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 200;
}

.aiia-menu--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.aiia-menu__heading {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.55);
}

.aiia-menu__item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
}

.aiia-menu__item:hover { background: rgba(255,255,255,0.06); }
.aiia-menu__item--active { color: #1283EB; }

.aiia-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.aiia-menu-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.aiia-menu-btn:active { transform: scale(0.92); }
.aiia-menu-btn svg { width: 18px; height: 18px; }

.aiia-menu__divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 6px 0;
}

.aiia-menu__theme {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
}

.aiia-menu__theme:hover { background: rgba(255,255,255,0.06); }

.aiia-menu__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ----- Canvas (main area) --------------------------------------------- */
.aiia-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 11; /* above header z-index:10 so back button stays clickable */
  container-type: inline-size;
  container-name: canvas;
}

/* Container queries for narrow canvas (drawer open) */
@container canvas (max-width: 600px) {
  .ds-kpi-row {
    flex-direction: column;
    gap: 24px;
    align-items: stretch;
  }
  .ds-kpi-focal, .ds-kpi-item {
    text-align: center;
  }
}

#aiia-canvas-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Canvas transition animations — spring easing for organic feel */
#aiia-canvas-content.exit { animation: compressOut 0.2s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
#aiia-canvas-content.enter { animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
#aiia-canvas-content > * { animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
#aiia-canvas-content > *:nth-child(2) { animation-delay: 0.05s; }
#aiia-canvas-content > *:nth-child(3) { animation-delay: 0.1s; }
#aiia-canvas-content > *:nth-child(4) { animation-delay: 0.15s; }
#aiia-canvas-content > *:nth-child(n+5) { animation-delay: 0.2s; }

/* ----- Pills ----------------------------------------------------------- */
.aiia-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0 0 16px;
  justify-content: center;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.25s ease;
}

/* When drawer is open, shrink content to make room */
.aiia-canvas,
.aiia-input-bar {
  transition: margin-right 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}
body.drawer-open .aiia-canvas {
  margin-right: 360px;
}
body.drawer-open .aiia-input-bar {
  /* Keep input bar centered within the space left of the drawer */
  width: calc(100% - 360px);
}
body.drawer-open .aiia-drawer-toggle {
  color: var(--aiia-blue);
}

.aiia-pills::-webkit-scrollbar { display: none; }

.aiia-pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
}

.aiia-pill:hover { opacity: 0.7; }
.aiia-pill:active { transform: scale(0.98); }
.aiia-pill--active {
  border-color: var(--aiia-blue);
  color: var(--aiia-blue);
  box-shadow: 0 0 8px rgba(43, 143, 232, 0.3), 0 0 24px rgba(43, 143, 232, 0.15);
}

/* ----- Input Bar ------------------------------------------------------- */
.aiia-input-bar {
  --aiia-chatbar-inline-pad: clamp(24px, 8vw, 100px);
  --aiia-chatbar-bottom-pad: max(100px, env(safe-area-inset-bottom));
  padding: 16px var(--aiia-chatbar-inline-pad) var(--aiia-chatbar-bottom-pad);
  flex-shrink: 0;
  position: relative;
}

.aiia-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #FFFFFF;
  border-radius: 24px;
  height: 48px;
  padding: 0 6px;
  box-shadow: var(--input-shadow);
  transition: box-shadow 0.15s ease;
  position: relative;
}

.aiia-input-wrap:focus-within {
  box-shadow: 0 0 0 2px rgba(18,131,235,0.15), 0 0 12px rgba(18,131,235,0.08);
  outline: none;
}

.aiia-input-wrap *:focus { outline: none; }

.aiia-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: #0a0a0a;
  line-height: 1.4;
  min-width: 0;
}

.aiia-input::placeholder { color: rgba(10,10,10,0.5); }
.aiia-input:disabled { opacity: 0.5; }

/* Plus button (left of input) */
.aiia-plus-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(10,10,10,0.4);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}

.aiia-plus-btn:hover { color: rgba(10,10,10,0.7); background: rgba(0,0,0,0.05); }
.aiia-plus-btn:active { transform: scale(0.92); }
.aiia-plus-btn--open { transform: rotate(45deg); color: rgba(10,10,10,0.7); }

/* Backdrop for bottom sheet */
.aiia-plus-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  display: none;
}
.aiia-plus-backdrop--open {
  display: block;
}

/* Drag handle (hidden on desktop) */
.aiia-bottom-sheet__handle { display: none; }

/* Plus menu (upward popover) */
.aiia-plus-menu {
  position: absolute;
  bottom: calc(100% - 8px);
  left: var(--aiia-chatbar-inline-pad);
  min-width: 180px;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 6px 0;
  z-index: 100;
  animation: menuFadeIn 0.15s ease;
}

.aiia-plus-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.1s ease;
  text-align: left;
}

.aiia-plus-menu__item:hover { background: rgba(255,255,255,0.08); }
.aiia-plus-menu__item:active { background: rgba(255,255,255,0.12); }
.aiia-plus-menu__item--disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.aiia-plus-menu__item svg { color: rgba(255,255,255,0.5); flex-shrink: 0; }

/* Scan type picker */
.aiia-scan-picker {
  position: absolute;
  bottom: calc(100% - 8px);
  left: 100px;
  min-width: 200px;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 6px 0;
  z-index: 100;
  animation: menuFadeIn 0.15s ease;
}

.aiia-scan-picker__title {
  padding: 8px 16px 4px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.55);
}

.aiia-scan-picker__item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease;
}

.aiia-scan-picker__item:hover { background: rgba(255,255,255,0.08); }
.aiia-scan-picker__item:active { background: rgba(255,255,255,0.12); }

@keyframes menuFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mic button (right of input) */
.aiia-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(10,10,10,0.4);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, width 0.2s ease, opacity 0.2s ease;
  padding: 0;
  flex-shrink: 0;
  position: relative;
}

.aiia-mic-btn:hover { color: rgba(10,10,10,0.7); background: rgba(0,0,0,0.05); }
.aiia-mic-btn:active { transform: scale(0.92); }

.aiia-mic-btn--hidden {
  width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.aiia-mic-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(18, 131, 235, 0.25);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.aiia-mic-btn--recording .aiia-mic-glow {
  opacity: 1;
  animation: micGlow 1.5s ease-in-out infinite;
}

.aiia-mic-btn--recording { color: #1283EB !important; }

@keyframes micGlow {
  0%, 100% { transform: scale(1); opacity: 0.25; }
  50% { transform: scale(1.2); opacity: 0.5; }
}

/* Send button */
.aiia-send-btn {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: #1283EB;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.1s ease, width 0.2s ease;
  color: #FFFFFF;
}

.aiia-send-btn--hidden {
  width: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
}

.aiia-send-btn:hover { opacity: 0.85; }
.aiia-send-btn:active { transform: scale(0.92); }
.aiia-send-btn:disabled { opacity: 0.3; cursor: default; }
.aiia-send-btn svg { width: 18px; height: 18px; min-width: 18px; }

/* Drawer toggle — in header */
.aiia-drawer-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  transition: color 0.15s ease, background 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.aiia-drawer-toggle:hover { color: #fff; background: rgba(255,255,255,0.08); }
.aiia-drawer-toggle:active { transform: scale(0.92); }
.aiia-drawer-toggle svg { width: 18px; height: 18px; }

/* ----- Attachment Staging ------------------------------------------------ */
.aiia-attachments {
  display: flex;
  gap: 8px;
  padding: 0 100px 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.aiia-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s ease;
}

.aiia-attachment:hover { background: rgba(255,255,255,0.12); }

.aiia-attachment__icon {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1;
}

.aiia-attachment__icon--pdf { background: #FF5E54; color: #fff; }
.aiia-attachment__icon--doc { background: #4285F4; color: #fff; }
.aiia-attachment__icon--xls { background: #34A853; color: #fff; }
.aiia-attachment__icon--csv { background: rgba(255,255,255,0.2); color: #fff; }
.aiia-attachment__icon--img { background: #1283EB; color: #fff; }
.aiia-attachment__icon--txt { background: rgba(255,255,255,0.2); color: #fff; }
.aiia-attachment__icon--file { background: rgba(255,255,255,0.15); color: #fff; }

.aiia-attachment__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aiia-attachment__remove {
  width: 16px;
  height: 16px;
  border: none;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  color: rgba(255,255,255,0.6);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.aiia-attachment__remove:hover { background: rgba(255,94,84,0.3); color: #FF5E54; }

/* Lightbox */
.aiia-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease;
}

.aiia-lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aiia-lightbox__close:hover { background: rgba(255,255,255,0.2); }

.aiia-lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
}

.aiia-lightbox__info {
  color: rgba(255,255,255,0.6);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  text-align: center;
}

.aiia-lightbox__filename {
  color: #fff;
  font-weight: 500;
}

@media (max-width: 640px) {
  .aiia-attachments { padding: 0 24px 8px; }
}

/* ----- Loading Animation ----------------------------------------------- */
.aiia-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 6px;
  padding: 40px 0;
}

.aiia-loading__dots {
  display: flex;
  gap: 4px;
}

.aiia-loading__dot,
.aiia-loading span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1283EB;
  opacity: 0.3;
  animation: loadingDot 0.6s ease-in-out infinite;
}

.aiia-loading__dot:nth-child(2),
.aiia-loading span:nth-child(2) { animation-delay: 0.15s; }

.aiia-loading__dot:nth-child(3),
.aiia-loading span:nth-child(3) { animation-delay: 0.3s; }

.aiia-loading__text {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.aiia-loading__retry {
  margin-top: 16px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #FFFFFF;
  font-size: 13px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

.aiia-loading__retry:hover { background: rgba(255,255,255,0.15); }

/* ----- Processing State (input bar) ------------------------------------ */
.aiia-input-wrap--processing {
  justify-content: flex-start;
  padding-left: 16px;
}

.aiia-processing-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aiia-processing-dots {
  display: flex;
  gap: 3px;
}

.aiia-processing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1283EB;
  opacity: 0.3;
  animation: loadingDot 0.6s ease-in-out infinite;
}

.aiia-processing-dots span:nth-child(2) { animation-delay: 0.15s; }
.aiia-processing-dots span:nth-child(3) { animation-delay: 0.3s; }

.aiia-processing-text {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: rgba(10,10,10,0.5);
}

/* ----- Mode Indicator -------------------------------------------------- */
.aiia-mode {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 50;
}

.aiia-mode--demo { background: #FF5E54; }
.aiia-mode--live { background: #1283EB; }

/* ----- Toast ----------------------------------------------------------- */
.aiia-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(18,18,18,0.92);
  border: 1px solid rgba(255,255,255,0.16);
  color: #FFFFFF;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 80;
  backdrop-filter: blur(10px);
}

/* ============================================================================
   Drawer
   ============================================================================ */
.aiia-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.aiia-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.aiia-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  height: 100dvh;
  background: #1a1a1a;
  border-left: 1px solid rgba(255,255,255,0.1);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 55;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aiia-drawer--open { transform: translateX(0); }

.aiia-drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.aiia-drawer__title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #FFFFFF;
}

.aiia-drawer__close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease;
}

.aiia-drawer__close:hover { background: rgba(255,255,255,0.15); }

/* Drawer — user card */
.aiia-drawer__user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.aiia-drawer__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--aiia-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
  flex-shrink: 0;
}
.aiia-drawer__user-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.aiia-drawer__user-name {
  font-size: 13px;
  font-weight: 500;
  color: #FFFFFF;
}
.aiia-drawer__user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
}
.aiia-drawer__switch-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.aiia-drawer__switch-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Drawer — switch user panel */
.aiia-drawer__switch-panel {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.aiia-drawer__switch-panel .aiia-menu__item {
  border-radius: 6px;
  padding: 8px 12px;
}

/* Drawer — locale toggle */
.aiia-drawer__locale-toggle {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.aiia-drawer__locale-toggle .aiia-menu__item {
  flex: 1;
  text-align: center;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
.aiia-drawer__locale-toggle .aiia-menu__item--active {
  background: rgba(255,255,255,0.08);
  color: var(--ds-accent, #2B8FE8);
}

/* Drawer — sessions header (sticky) */
.aiia-drawer__sessions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  flex-shrink: 0;
}
.aiia-drawer__heading {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.aiia-drawer__new-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.aiia-drawer__new-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Drawer — session list (scrollable, 2/5 of remaining space) */
.aiia-drawer__sessions {
  flex: 2;
  overflow-y: auto;
  padding: 0 8px;
  min-height: 0;
}
.aiia-drawer__session-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.aiia-session-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.1s ease;
}
.aiia-session-item:hover { background: rgba(255,255,255,0.06); }
.aiia-session-item--active { background: rgba(43,143,232,0.1); }
.aiia-session-item__query {
  font-size: 13px;
  color: #F8F3EC;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aiia-session-item__meta {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
}
.aiia-session-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  padding: 12px;
}

/* Drawer — resize handle */
.aiia-drawer__resize-handle {
  height: 6px;
  cursor: row-resize;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aiia-drawer__resize-handle::after {
  content: '';
  width: 32px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255,255,255,0.15);
}
.aiia-drawer__resize-handle:hover::after { background: rgba(255,255,255,0.3); }

/* Drawer — active chat (3/5 of remaining space) */
.aiia-drawer__chat {
  flex: 3;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
/* Drawer — chat messages (aligned left/right) */
.aiia-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  padding: 0;
  background: transparent;
  border: none;
}
.aiia-chat-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}
.aiia-chat-msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.aiia-chat-msg__sender {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.aiia-chat-msg__text {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  line-height: 1.5;
}
.aiia-chat-msg__time {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
}

/* Drawer — processing indicator */
.aiia-drawer__processing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  align-self: flex-start;
}
.aiia-drawer__processing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--aiia-blue);
  opacity: 0.3;
  animation: loadingDot 0.6s ease-in-out infinite;
}
.aiia-drawer__processing span:nth-child(2) { animation-delay: 0.15s; }
.aiia-drawer__processing span:nth-child(3) { animation-delay: 0.3s; }

/* Drawer — chat input */
.aiia-drawer__input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.aiia-drawer__input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #FFFFFF;
  outline: none;
}
.aiia-drawer__input::placeholder { color: rgba(255,255,255,0.3); }
.aiia-drawer__input:focus { border-color: var(--aiia-blue); }
.aiia-drawer__send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--aiia-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.aiia-drawer__send:hover { opacity: 0.85; }

/* ============================================================================
   Animations
   ============================================================================ */
@keyframes compressOut {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.95) translateY(-10px); opacity: 0; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes loadingDot {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ============================================================================
   Responsive
   ============================================================================ */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  #aiia-canvas-content.exit,
  #aiia-canvas-content.enter,
  #aiia-canvas-content > * { animation: none !important; }
  .aiia-loading span, .aiia-loading__dot { animation: none !important; opacity: 1; }
}

/* Desktop */
@media (min-width: 768px) {
  .aiia-header {
    height: 64px;
    padding: 0 40px;
  }

  #aiia-canvas-content {
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
  }

  .aiia-pills { padding: 0 40px 16px; }
  .aiia-pill { font-size: 14px; }

  .aiia-input-bar {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }

  .aiia-input-wrap {
    border-radius: 26px;
    height: 52px;
  }

  /* Design system desktop overrides */
  .ds-hero-number { font-size: 56px; }
  .ds-greeting .ds-hero-number { font-size: 56px; }
  .ds-urgency { max-width: 700px; }
  .ds-kpi-grid { max-width: 700px; }
}

/* Mobile */
@media (max-width: 640px) {
  .aiia-header { padding: 0 12px; }

  #aiia-canvas-content { padding: 0 8px 12px; }

  .aiia-pills {
    padding: 0 8px 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .aiia-input-bar {
    --aiia-chatbar-inline-pad: 24px;
    --aiia-chatbar-bottom-pad: 24px;
    padding: 8px var(--aiia-chatbar-inline-pad) var(--aiia-chatbar-bottom-pad);
  }
  .aiia-drawer { width: 100%; }
  body.drawer-open .aiia-canvas,
  body.drawer-open .aiia-input-bar { margin-right: 0; }

  /* Design system mobile overrides */
  .ds-greeting-row { flex-direction: column; gap: var(--ds-space-3); align-items: center; }
  .ds-greeting-inline { justify-content: center; }
  .ds-greeting-context { font-size: 20px; }
  .ds-greeting-name { font-size: 20px; }
  .ds-hero-number { font-size: 36px; }
  .ds-greeting .ds-hero-number { font-size: 36px; }
  .ds-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ds-kpi-row { flex-direction: column; gap: var(--ds-space-3); }
  .ds-summary { flex-direction: column; gap: var(--ds-space-2); }
  .ds-chart-row { grid-template-columns: 80px 1fr 40px; }
  .ds-table th { font-size: 10px; padding: 6px 8px 6px 0; }
  .ds-table td { font-size: 12px; padding: 6px 8px 6px 0; }
  .ds-table th:nth-child(n+4),
  .ds-table td:nth-child(n+4) { display: none; }

  /* Bottom sheet for + menu on mobile */
  .aiia-plus-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: unset;
    border-radius: 16px 16px 0 0;
    padding: 8px 0 calc(16px + env(safe-area-inset-bottom));
    animation: sheetSlideUp 0.25s ease;
    z-index: 200;
  }

  .aiia-scan-picker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: unset;
    border-radius: 16px 16px 0 0;
    padding: 8px 0 calc(16px + env(safe-area-inset-bottom));
    animation: sheetSlideUp 0.25s ease;
    z-index: 200;
  }

  .aiia-plus-menu__item {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 48px;
  }

  .aiia-scan-picker__item {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 48px;
  }

  .aiia-bottom-sheet__handle {
    display: flex;
    justify-content: center;
    padding: 8px 0;
  }

  .aiia-bottom-sheet__handle span {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.3);
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

@media (max-width: 400px) {
  .aiia-drawer { width: calc(100vw - 16px); }
}

/* Utility — hidden */
.hidden { display: none !important; }
