:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #7c3aed;
  --accent: #3b82f6;
  --background: #1e1b4b;
  --surface: rgba(30, 27, 75, 0.95);
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --error: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563eb, #7c3aed);
  --gradient-surface: linear-gradient(180deg, var(--surface), rgba(30, 27, 75, 0.98));

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Quick Access Mode Styles */
.quick-access-container {
  position: fixed;
  z-index: 10001;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition-normal);
}

.quick-access-pill {
  background: var(--gradient-primary);
  border-radius: 24px;
  padding: 8px 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-fast);
}

.quick-access-pill:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.quick-access-pill:active {
  transform: translateY(1px);
}

.quick-access-pill .icon {
  width: 20px;
  height: 20px;
  opacity: 0.9;
}

.quick-response-panel {
  background: var(--gradient-surface);
  border-radius: 16px;
  padding: 16px;
  width: 300px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  transition: all var(--transition-normal);
  transform-origin: bottom right;
}

.quick-response-panel.hidden {
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
}

.quick-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
  resize: none;
  transition: all var(--transition-fast);
}

.quick-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.quick-responses {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 300px;
  padding-right: 4px;
}

.quick-response {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: fadeIn 0.3s ease-out;
}

.quick-response:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.quick-response:active {
  transform: translateY(1px);
}

.quick-categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.quick-categories::-webkit-scrollbar {
  display: none;
}

.quick-category {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-category.active {
  background: var(--gradient-primary);
  color: var(--text);
  border-color: transparent;
}

/* Floating Action Button */
.action-button {
  background: var(--gradient-primary);
  width: 48px;
  height: 48px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  border: none;
  color: var(--text);
  transition: all var(--transition-fast);
}

.action-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.action-button:active {
  transform: translateY(1px);
}

.action-button .icon {
  width: 24px;
  height: 24px;
  opacity: 0.9;
}

/* Copy Animation */
@keyframes copyFlash {
  0% { transform: scale(1); background: var(--success); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.copy-animation {
  animation: copyFlash 0.3s ease-out;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
  .quick-response-panel {
    width: calc(100vw - 40px);
    max-height: 60vh;
    bottom: 80px;
  }

  .quick-access-container {
    bottom: env(safe-area-inset-bottom, 20px);
    right: env(safe-area-inset-right, 20px);
  }

  .app-container.collapsed {
    transform: scale(0.95);
    opacity: 0;
    pointer-events: none;
  }
}

/* High Contrast & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .quick-access-pill,
  .quick-response-panel,
  .quick-response,
  .action-button {
    transition: none;
  }
}

@media (forced-colors: active) {
  .quick-access-pill,
  .quick-response-panel,
  .quick-response,
  .action-button {
    border: 2px solid ButtonText;
  }
}

/* Animations */
@keyframes slideIn {
  from { 
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

/* App Container */
.app-container {
  position: fixed;
  z-index: 10000;
  max-width: 99vw;
  width: 400px;
  max-height: 99vh;
  height: 600px;
  background: var(--gradient-surface);
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transform-origin: center bottom;
  transition: all var(--transition-normal);
}

/* Mode Switcher */
.mode-switcher {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border-radius: 20px;
  padding: 4px;
  display: flex;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10001;
  box-shadow: var(--shadow-lg);
  width: auto;
  min-width: 200px;
}

.mode-button {
  flex: 1;
  padding: 8px 16px;
  border-radius: 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.mode-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mode-button.active {
  background: var(--gradient-primary);
  color: white;
}

.mode-button .icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

/* Header */
.app-header {
  background: var(--gradient-primary);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.app-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.1) 50%,
    rgba(255,255,255,0) 100%);
  animation: shimmer 3s infinite linear;
}

.logo-text {
  font-weight: 700;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.app-subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Input Container */
.input-container {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
}

.message-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 0.9rem;
  resize: none;
  transition: all var(--transition-fast);
}

.message-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.input-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.char-counter {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Analyze Button */
.analyze-button {
  background: var(--gradient-primary);
  color: white;
  padding: 10px 20px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.analyze-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.analyze-button:active {
  transform: translateY(1px);
}

/* Loading Indicator */
.loading-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.loading-dot {
  width: 4px;
  height: 4px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

/* Context Analysis */
.context-analysis {
  margin: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.analysis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.analysis-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.analysis-score {
  font-size: 0.8rem;
  color: var(--accent);
}

.analysis-context {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.analysis-tips {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Response Categories */
.response-categories {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: rgba(0, 0, 0, 0.1);
}

.response-categories::-webkit-scrollbar {
  display: none;
}

.category-tab {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-tab.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.category-icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

/* Responses Container */
.responses-container {
  padding: 16px;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 400px);
  overflow-y: auto;
}

.response-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--text);
  text-align: left;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  animation: fadeIn 0.3s ease-out;
}

.response-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.response-pill:active {
  transform: translateY(1px);
}

/* Persona Grid */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 16px;
}

.persona-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.persona-card:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.persona-card.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

.persona-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.avatar-emoji {
  font-size: 2rem;
}

.persona-info {
  text-align: center;
}

.persona-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.persona-trait {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Chat Container */
.chat-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 80%;
  padding: 12px;
  border-radius: 16px;
  animation: fadeIn 0.3s ease-out;
  position: relative;
}

.message.user {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.bot {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}

.chat-input-container {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 8px;
}

  [Previous CSS content remains exactly the same until chat-input...]

  .chat-input {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    color: var(--text);
    font-size: 0.9rem;
    resize: none;
    height: 48px;
    max-height: 120px;
    transition: all var(--transition-fast);
  }

  .chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
  }

  .send-button {
    background: var(--primary);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .send-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
  }

  .send-button:active {
    transform: translateY(1px);
  }

  /* Toast Notifications */
  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease-out;
    z-index: 10001;
    box-shadow: var(--shadow-lg);
  }

  /* Utility Classes */
  .hidden {
    display: none !important;
  }

  .flex {
    display: flex;
  }

  .items-center {
    align-items: center;
  }

  .justify-between {
    justify-content: space-between;
  }

  .gap-2 {
    gap: 8px;
  }

  .gap-3 {
    gap: 12px;
  }

  .text-sm {
    font-size: 0.875rem;
  }

  .text-xs {
    font-size: 0.75rem;
  }

  .font-semibold {
    font-weight: 600;
  }

  .text-white\/70 {
    color: rgba(255, 255, 255, 0.7);
  }

  .text-white\/90 {
    color: rgba(255, 255, 255, 0.9);
  }

  .mb-2 {
    margin-bottom: 8px;
  }

  .mt-2 {
    margin-top: 8px;
  }

  .w-8 {
    width: 32px;
  }

  .h-8 {
    height: 32px;
  }

  /* Scrollbar Styling */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  /* Responsive Design */
  @media (max-width: 640px) {
    .app-container {
      width: 100vw;
      height: 100vh;
      max-width: 100vw;
      max-height: 100vh;
      border-radius: 0;
      left: 0 !important;
      bottom: 0 !important;
    }

    .mode-switcher {
      top: 12px;
      width: calc(100% - 32px);
    }

    .persona-grid {
      grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .chat-messages {
      padding: 12px;
    }

    .message {
      max-width: 90%;
    }

    .response-categories {
      padding: 8px 12px;
    }

    .category-tab {
      padding: 6px 12px;
      font-size: 0.8rem;
    }
  }

  /* Dark Mode Support */
  @media (prefers-color-scheme: dark) {
    :root {
      --surface: rgba(17, 24, 39, 0.95);
      --background: #111827;
    }
  }

  /* Focus Visible Polyfill */
  .js-focus-visible :focus:not(.focus-visible) {
    outline: none;
  }

  .js-focus-visible .focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* Print Styles */
  @media print {
    .app-container {
      display: none;
    }
  }

  /* Reduced Motion */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  /* High Contrast Mode */
  @media (forced-colors: active) {
    .app-container {
      border: 2px solid CanvasText;
    }

    .mode-button.active {
      border: 2px solid CanvasText;
    }
  }