/* Modern Dark Logistics CSS Tokens & Theme */
:root {
  --color-primary: #96cf1e;
  --color-primary-hover: #a9e52a;
  --color-primary-dark: #6f9f0f;

  --color-secondary: #1b70de;
  --color-secondary-hover: #3184ed;
  --color-secondary-dark: #1457ad;

  --color-bg: #080c13;
  --color-bg-soft: #0d131d;
  --color-surface: #111925;
  --color-surface-elevated: #172231;
  --color-surface-hover: #1d2a3b;

  --color-border: rgba(255, 255, 255, 0.09);
  --color-border-strong: rgba(150, 207, 30, 0.3);

  --color-text-primary: #f4f7fb;
  --color-text-secondary: #aeb9c8;
  --color-text-muted: #738095;

  --color-success: #96cf1e;
  --color-info: #1b70de;
  --color-warning: #f5b942;
  --color-danger: #ff5c68;

  /* Icon Design Tokens */
  --icon-primary: #96cf1e;
  --icon-secondary: #1b70de;
  --icon-light: #f4f7fb;
  --icon-muted: #7f8da3;
  --icon-danger: #ff5c68;
  --icon-warning: #f5b942;
  --icon-bg-primary: rgba(150, 207, 30, 0.12);
  --icon-bg-secondary: rgba(27, 112, 222, 0.14);
  --icon-bg-danger: rgba(255, 92, 104, 0.12);
  --icon-bg-neutral: rgba(255, 255, 255, 0.06);

  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.35);
  --shadow-primary: 0 10px 30px rgba(150, 207, 30, 0.15);
  --shadow-secondary: 0 10px 30px rgba(27, 112, 222, 0.2);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: var(--font-family);
  background:
    radial-gradient(circle at top left, rgba(27, 112, 222, 0.16), transparent 35%),
    radial-gradient(circle at bottom right, rgba(150, 207, 30, 0.10), transparent 30%),
    var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

/* Accessible Hidden Element */
.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;
}

:focus-visible {
  outline: 2px solid var(--color-secondary-hover);
  outline-offset: 2px;
}

/* Icon Utility System */
.app-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.app-icon.icon-sm { width: 16px; height: 16px; }
.app-icon.icon-md { width: 22px; height: 22px; }
.app-icon.icon-lg { width: 26px; height: 26px; }
.app-icon.icon-xl { width: 44px; height: 44px; }

.icon-primary { color: var(--icon-primary); }
.icon-secondary { color: var(--icon-secondary); }
.icon-light { color: var(--icon-light); }
.icon-muted { color: var(--icon-muted); }
.icon-danger { color: var(--icon-danger); }
.icon-warning { color: var(--icon-warning); }

/* App Container (Desktop Default) */
.app-container {
  background: rgba(17, 25, 37, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: 100%;
  max-width: 1080px;
  height: 92vh;
  height: 92dvh;
  max-height: 860px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

/* 1. App Header */
.app-header {
  background-color: var(--color-surface);
  padding: 14px 22px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.brand-logo-link:hover {
  transform: scale(1.02);
}

.brand-logo {
  width: clamp(170px, 22vw, 280px);
  height: auto;
  max-height: 92px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.35));
}

.header-status-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  transition: all 0.3s ease;
  white-space: nowrap;
}

.status-pill.online {
  background-color: rgba(150, 207, 30, 0.12);
  color: var(--color-primary);
  border: 1px solid rgba(150, 207, 30, 0.3);
}

.status-pill.offline {
  background-color: rgba(255, 92, 104, 0.12);
  color: var(--color-danger);
  border: 1px solid rgba(255, 92, 104, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-pill.online .status-dot {
  background-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(150, 207, 30, 0.25);
}

.status-pill.offline .status-dot {
  background-color: var(--color-danger);
  box-shadow: 0 0 0 2px rgba(255, 92, 104, 0.25);
}

.simulation-badge {
  background-color: rgba(27, 112, 222, 0.15);
  color: var(--color-secondary-hover);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(27, 112, 222, 0.3);
  white-space: nowrap;
}

/* 2. Welcome Section / Hero */
.welcome-banner {
  padding: 12px 22px 4px 22px;
  flex-shrink: 0;
}

.welcome-card {
  background: linear-gradient(135deg, rgba(27, 112, 222, 0.12) 0%, rgba(150, 207, 30, 0.07) 100%);
  border: 1px solid rgba(27, 112, 222, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.welcome-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.welcome-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.highlight-lime {
  color: var(--color-primary);
  font-weight: 700;
}

.welcome-card p {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.simulation-notice {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(13, 19, 29, 0.6);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  line-height: 1.3;
}

/* 3. Quick Action Buttons */
.quick-actions {
  display: flex;
  gap: 10px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  min-height: 42px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.action-btn.primary-action {
  background-color: var(--color-primary);
  color: #080c13;
  font-weight: 700;
  border: none;
  box-shadow: var(--shadow-primary);
}

.action-btn.primary-action:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

.action-btn.secondary-action {
  background-color: rgba(27, 112, 222, 0.15);
  color: #ffffff;
  border: 1px solid var(--color-secondary);
  box-shadow: var(--shadow-secondary);
}

.action-btn.secondary-action:hover:not(:disabled) {
  background-color: rgba(27, 112, 222, 0.25);
  border-color: var(--color-secondary-hover);
  transform: translateY(-1px);
}

.action-btn.neutral-action {
  background-color: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.action-btn.neutral-action:hover:not(:disabled) {
  background-color: var(--color-surface-hover);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

.action-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 4. Chat Main Area */
.chat-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: var(--color-bg-soft);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Message Rows, Metadata, and Avatars */
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 85%;
  animation: fadeInMsg 0.25s ease forwards;
}

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

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.bot {
  align-self: flex-start;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.725rem;
  margin-bottom: 2px;
}

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

.message-author {
  font-weight: 700;
  color: var(--color-primary);
}

.message-author.user-author {
  color: var(--color-secondary-hover);
}

.message-time {
  color: var(--color-text-muted);
}

/* Message Avatars */
.message-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.bot-avatar {
  padding: 5px;
  background: linear-gradient(145deg, rgba(150, 207, 30, 0.14), rgba(27, 112, 222, 0.12)), #111925;
  border: 1px solid rgba(150, 207, 30, 0.32);
  box-shadow: 0 8px 22px rgba(150, 207, 30, 0.10);
}

.bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.user-avatar {
  border-radius: 50%;
  background: linear-gradient(145deg, #1b70de, #1457ad);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 20px rgba(27, 112, 222, 0.18);
}

.user-avatar svg {
  width: 54%;
  height: 54%;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.48;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-row.user .bubble {
  background: linear-gradient(135deg, #1b70de 0%, #165dbd 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: var(--shadow-secondary);
}

.message-row.bot .bubble {
  background-color: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-top-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Interactive Wizard Cards */
.wizard-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.wizard-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wizard-title .app-icon { width: 22px; height: 22px; }

.wizard-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wizard-option-btn {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-height: 44px;
  font-family: inherit;
  font-size: 0.84375rem;
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  width: 100%;
}

.wizard-option-btn:hover:not(:disabled) {
  background-color: var(--color-surface-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.wizard-option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wizard-option-btn.selected {
  background-color: var(--color-secondary);
  color: #ffffff;
  border-color: var(--color-secondary);
}

.wizard-cancel-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  align-self: flex-start;
  min-height: 36px;
  padding: 4px 0;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wizard-cancel-btn:hover {
  color: var(--color-text-secondary);
}

.wizard-cancel-btn .app-icon { width: 14px; height: 14px; }

/* Result Cards & Summaries */
.result-card, .summary-card, .tracking-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.775rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  align-self: flex-start;
}

.result-badge.eligible {
  background-color: rgba(150, 207, 30, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(150, 207, 30, 0.3);
}

.result-badge.review {
  background-color: rgba(245, 185, 66, 0.15);
  color: var(--color-warning);
  border: 1px solid rgba(245, 185, 66, 0.3);
}

.result-badge.rejected {
  background-color: rgba(255, 92, 104, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(255, 92, 104, 0.3);
}

.result-requirements {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.result-requirements h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-text-primary);
}

.result-requirements ul {
  padding-left: 18px;
}

.wizard-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.wizard-action-btn {
  padding: 8px 14px;
  min-height: 44px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.wizard-action-btn.primary {
  background-color: var(--color-primary);
  color: #080c13;
  font-weight: 700;
}

.wizard-action-btn.primary:hover {
  background-color: var(--color-primary-hover);
}

.wizard-action-btn.secondary {
  background-color: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.wizard-action-btn.secondary:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.wizard-action-btn.ai {
  background-color: rgba(27, 112, 222, 0.18);
  color: #ffffff;
  border-color: rgba(27, 112, 222, 0.35);
}

.wizard-action-btn.ai:hover {
  background-color: rgba(27, 112, 222, 0.3);
}

/* Return Summary Card */
.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.summary-header {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-primary);
}

.code-box {
  background-color: var(--color-bg);
  border: 1.5px dashed var(--color-primary);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.code-value {
  font-family: monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.5px;
  overflow-wrap: anywhere;
}

.copy-btn {
  background-color: var(--color-secondary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  min-height: 40px;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.copy-btn:hover {
  background-color: var(--color-secondary-hover);
}

.address-box {
  background-color: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.address-title {
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.simulation-address-notice {
  font-size: 0.725rem;
  color: var(--color-warning);
  background-color: rgba(245, 185, 66, 0.12);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 185, 66, 0.25);
  margin-top: 8px;
  line-height: 1.3;
}

.refund-warning-box {
  background-color: rgba(255, 92, 104, 0.12);
  border: 1px solid rgba(255, 92, 104, 0.25);
  color: #ffa4ab;
  font-size: 0.75rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.3;
}

/* Tracking Timeline Styling */
.tracking-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.tracking-notice {
  font-size: 0.725rem;
  color: var(--color-warning);
  background-color: rgba(245, 185, 66, 0.12);
  border: 1px solid rgba(245, 185, 66, 0.25);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  line-height: 1.3;
}

.tracking-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  background-color: var(--color-bg-soft);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.775rem;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.675rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.info-val {
  font-weight: 700;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

.timeline-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: 4px;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 20px;
}

.timeline-list::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background-color: var(--color-border);
}

.timeline-step {
  position: relative;
  padding-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.timeline-step:last-child {
  padding-bottom: 0;
}

.timeline-step .node-icon {
  position: absolute;
  left: -20px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--color-surface);
  border: 2px solid var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  z-index: 1;
}

.timeline-step.completed .node-icon {
  border-color: var(--color-primary);
  background-color: var(--color-primary);
  color: #080c13;
}

.timeline-step.current .node-icon {
  border-color: var(--color-secondary);
  background-color: var(--color-secondary);
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(27, 112, 222, 0.25);
}

.timeline-step .step-name {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.timeline-step.completed .step-name {
  color: var(--color-text-primary);
}

.timeline-step.current .step-name {
  color: var(--color-primary);
  font-weight: 700;
}

.timeline-step .step-time {
  font-size: 0.675rem;
  color: var(--color-text-muted);
}

/* Demo Simulation Box */
.demo-mode-box {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.demo-title {
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--color-secondary-hover);
}

.demo-btn {
  background-color: var(--color-secondary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-height: 40px;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: all 0.2s ease;
  width: 100%;
  text-align: center;
}

.demo-btn:hover:not(:disabled) {
  background-color: var(--color-secondary-hover);
}

.demo-btn:disabled {
  background-color: var(--color-surface);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* Toast In-App Notification */
.toast-notification {
  position: fixed;
  bottom: calc(75px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-strong);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  text-align: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  align-self: flex-start;
}

.typing-bubble {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-text {
  font-size: 0.775rem;
  color: var(--color-text-secondary);
  margin-right: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.dot.dot-lime { background-color: var(--color-primary); }
.dot.dot-blue { background-color: var(--color-secondary); animation-delay: 0.2s; }
.dot.dot-muted { background-color: var(--color-text-muted); animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Error Banner */
.error-banner {
  background-color: rgba(255, 92, 104, 0.12);
  border-top: 1px solid rgba(255, 92, 104, 0.25);
  border-bottom: 1px solid rgba(255, 92, 104, 0.25);
  color: #ffa4ab;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.close-error-btn {
  background: none;
  border: none;
  color: #ffa4ab;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  min-height: 36px;
}

/* 5. Chat Footer & Input Area Composer */
.chat-footer {
  padding: 14px 22px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input-wrapper {
  flex: 1;
}

.chat-input {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem; /* 16px on mobile prevents iOS auto-zoom */
  color: var(--color-text-primary);
  background-color: var(--color-bg-soft);
  transition: all 0.2s ease;
  min-height: 44px;
}

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

.chat-input:focus {
  background-color: var(--color-surface-elevated);
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(27, 112, 222, 0.2);
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-group {
  display: flex;
  gap: 8px;
}

.send-btn {
  background-color: var(--color-primary);
  color: #080c13;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  min-height: 44px;
  min-width: 44px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-primary);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.reset-btn {
  background-color: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.reset-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reset-btn:hover:not(:disabled) {
  background-color: rgba(255, 92, 104, 0.15);
  border-color: rgba(255, 92, 104, 0.3);
  color: var(--color-danger);
}

.reset-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

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

/* ==================================================
   RESPONSIVE MEDIA QUERIES
   ================================================== */

/* Desktop & Laptop (1024px to 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
  .app-container {
    max-width: 960px;
    height: 90vh;
    height: 90dvh;
  }

  .brand-logo {
    width: clamp(200px, 22vw, 250px);
    max-height: 84px;
  }
}

/* Tablet Portrait (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  body {
    padding: 12px;
  }

  .app-container {
    width: calc(100% - 24px);
    max-width: none;
    height: calc(100dvh - 24px);
    max-height: none;
    margin: 0 auto;
    border-radius: var(--radius-lg);
  }

  .app-header {
    padding: 12px 18px;
  }

  .brand-logo {
    width: clamp(180px, 25vw, 230px);
    max-height: 76px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 18px;
  }

  .action-btn {
    width: 100%;
    min-height: 44px;
  }

  .message-row {
    max-width: 88%;
    gap: 10px;
  }

  .message-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 13px;
    padding: 4px;
  }
}

/* Mobile Standard (481px to 767px) */
@media (max-width: 767px) {
  body {
    padding: 0;
  }

  .app-container {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .app-header {
    padding: 10px 14px;
  }

  .brand-logo {
    width: clamp(160px, 45vw, 210px);
    max-height: 68px;
  }

  .welcome-banner {
    padding: 8px 12px 2px 12px;
  }

  .welcome-card {
    padding: 10px 12px;
  }

  .welcome-card p {
    font-size: 0.775rem;
    margin-bottom: 6px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 6px 12px 8px 12px;
  }

  .action-btn {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 0.8125rem;
    white-space: normal;
    text-align: center;
  }

  .chat-main {
    padding: 12px 14px;
  }

  .message-row {
    max-width: 92%;
    gap: 8px;
  }

  .message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 12px;
    padding: 4px;
  }

  .chat-footer {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Mobile Small (max-width: 480px) */
@media (max-width: 480px) {
  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
  }

  .brand-logo {
    width: clamp(140px, 42vw, 185px);
    max-height: 60px;
  }

  .header-status-group {
    max-width: 140px;
    justify-content: flex-end;
    gap: 4px;
  }

  .status-pill {
    padding: 4px 8px;
    font-size: 0.6875rem;
  }

  .simulation-badge {
    padding: 4px 8px;
    font-size: 0.6875rem;
  }

  .welcome-banner {
    padding: 6px 10px 2px 10px;
  }

  .welcome-card {
    padding: 8px 10px;
  }

  .welcome-header h2 {
    font-size: 0.84375rem;
  }

  .welcome-card p {
    font-size: 0.75rem;
    margin-bottom: 4px;
  }

  .simulation-notice {
    font-size: 0.6875rem;
    padding: 4px 6px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px 10px;
  }

  .action-btn {
    min-height: 44px;
    padding: 6px 8px;
    font-size: 0.775rem;
  }

  .chat-main {
    padding: 10px;
    gap: 10px;
  }

  .message-row {
    max-width: 95%;
    gap: 8px;
  }

  .message-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .bubble {
    font-size: 0.84375rem;
    padding: 10px 12px;
  }

  .chat-footer {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .send-btn {
    padding: 8px 14px;
  }
}

/* Mobile Extra Small (max-width: 360px) */
@media (max-width: 360px) {
  .brand-logo {
    width: clamp(130px, 40vw, 160px);
    max-height: 52px;
  }

  .quick-actions {
    gap: 4px;
    padding: 4px 8px;
  }

  .action-btn {
    font-size: 0.725rem;
    padding: 4px 6px;
  }

  .message-row {
    max-width: 98%;
    gap: 6px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }
}

/* Mobile / Tablet Landscape (orientation: landscape and max-height: 600px) */
@media (orientation: landscape) and (max-height: 600px) {
  body {
    padding: 0;
  }

  .app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .app-header {
    padding: 6px 14px;
  }

  .brand-logo {
    width: clamp(140px, 20vw, 190px);
    max-height: 54px;
  }

  .welcome-banner {
    display: none;
  }

  .quick-actions {
    display: flex;
    padding: 4px 14px;
    overflow-x: auto;
  }

  .action-btn {
    min-height: 38px;
    padding: 4px 12px;
    font-size: 0.75rem;
  }

  .chat-main {
    padding: 8px 14px;
  }

  .chat-footer {
    padding: 6px 14px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .chat-input, .send-btn, .reset-btn {
    min-height: 38px;
  }
}
