/* ==========================================================================
   DasTool Theme - Bootstrap Overrides & Design Tokens
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --color-accent: #00b894;
  --color-accent-hover: #00a884;
  --color-accent-secondary: #00a8cc;
  --color-on-accent: #ffffff;
  --gradient-accent: linear-gradient(135deg, #00b894 0%, #00a8cc 100%);
  
  /* Background Colors */
  --color-bg: #ffffff;
  --color-bg-elevated: #f8fafc;
  --color-bg-card: #ffffff;
  --gradient-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  
  /* Text Colors */
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-secondary: #94a3b8;
  
  /* Border Colors */
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-hover: rgba(0, 184, 148, 0.4);
  
  /* Typography */
  --font-display: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 60px rgba(0, 184, 148, 0.1);
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* --------------------------------------------------------------------------
   Base Styles
   -------------------------------------------------------------------------- */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-display);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--color-text);
  text-wrap: balance;
}

/* Alpine.js cloak */
[x-cloak] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Navbar
   -------------------------------------------------------------------------- */
.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 0;
  transition: background-color var(--transition-slow), border-color var(--transition-slow);
  z-index: 1030;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text) !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand:hover {
  color: var(--color-text) !important;
}

.navbar .nav-link {
  color: var(--color-text-muted) !important;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition-base);
  padding: 0.5rem 1rem !important;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: var(--color-text) !important;
}

.navbar .nav-link.active {
  color: var(--color-accent) !important;
  font-weight: 600;
}

/* Navbar dropdown */
.navbar .dropdown-menu {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.5rem;
  z-index: 1050;
}

.navbar .dropdown-item {
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  color: var(--color-text);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus {
  background: var(--color-bg-elevated);
  color: var(--color-text);
}

.navbar .dropdown-header {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.navbar .dropdown-divider {
  border-color: var(--color-border);
  margin: 0.25rem 0;
}

/* Mobile navbar toggle */
.navbar-toggler {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.25rem rgba(0, 184, 148, 0.25);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-base), border-color var(--transition-base), color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
  font-size: 0.95rem;
}

.btn:focus {
  box-shadow: 0 0 0 0.25rem rgba(0, 184, 148, 0.25);
}

/* Primary button - uses accent color */
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: var(--color-on-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

.btn-primary:active {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  transform: scale(0.96);
}

/* Accent button - gradient style */
.btn-accent {
  background: var(--gradient-accent);
  border: none;
  color: var(--color-on-accent);
}

.btn-accent:hover,
.btn-accent:focus {
  color: var(--color-on-accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 184, 148, 0.3);
  filter: brightness(1.1);
}

.btn-accent:active {
  transform: scale(0.96);
}

/* Outline buttons */
.btn-outline-primary {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-outline-secondary {
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background: var(--color-bg-elevated);
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--color-text);
}

.btn-outline-secondary:active {
  transform: scale(0.96);
}

.btn-outline-dark {
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-outline-dark:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--color-text);
}

/* Button sizes */
.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-slow);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

.card-header:first-child {
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  background: var(--color-bg-elevated);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 1.5rem;
}

.card-footer:last-child {
  border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px);
}

.card-title {
  color: var(--color-text);
  font-weight: 600;
}

.card-title a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--transition-base);
}

.card-title a:hover {
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   List Groups
   -------------------------------------------------------------------------- */
.list-group {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-group-item {
  background: var(--color-bg-card);
  border-color: var(--color-border);
  padding: 1rem 1.25rem;
  transition: background-color var(--transition-base), color var(--transition-base);
}

.list-group-item:first-child {
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.list-group-item:last-child {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.list-group-item-action:hover,
.list-group-item-action:focus {
  background: var(--color-bg-elevated);
  color: var(--color-text);
}

.list-group-item-action:active {
  background: rgba(0, 184, 148, 0.1);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-control,
.form-select {
  font-family: var(--font-display);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.625rem 1rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.form-control:focus,
.form-select:focus {
  background: var(--color-bg-card);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.15);
  color: var(--color-text);
}

.form-control::placeholder {
  color: var(--color-text-secondary);
}

.form-label {
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

textarea.form-control {
  min-height: 100px;
}

/* Form validation states */
.form-control.is-valid {
  border-color: var(--color-accent);
}

.form-control.is-valid:focus {
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.15);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid;
  padding: 1rem 1.25rem;
}

.alert-info {
  background: rgba(0, 184, 148, 0.1);
  border-color: rgba(0, 184, 148, 0.3);
  color: var(--color-text);
}

.alert-info .alert-heading {
  color: var(--color-accent);
}

.alert-success {
  background: rgba(0, 184, 148, 0.1);
  border-color: rgba(0, 184, 148, 0.3);
  color: var(--color-text);
}

.alert-warning {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
  color: var(--color-text);
}

.alert-danger {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.3);
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
  font-family: var(--font-display);
  font-weight: 500;
  border-radius: 100px;
  padding: 0.35em 0.75em;
}

.bg-primary {
  background: var(--color-accent) !important;
}

.text-bg-primary {
  background-color: var(--color-accent) !important;
  color: var(--color-on-accent) !important;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table {
  --bs-table-bg: var(--color-bg-card);
  --bs-table-hover-bg: var(--color-bg-elevated);
  border-color: var(--color-border);
}

.table thead th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.table tbody td {
  color: var(--color-text);
  vertical-align: middle;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-bg-type: var(--color-bg-elevated);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pagination {
  gap: 0.25rem;
}

.page-link {
  font-family: var(--font-display);
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm) !important;
  color: var(--color-text);
  padding: 0.5rem 0.875rem;
  transition: all var(--transition-base);
}

.page-link:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border);
  color: var(--color-text);
}

.page-link:focus {
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.15);
}

.page-item.active .page-link {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

.page-item.disabled .page-link {
  background: var(--color-bg-elevated);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.modal-content {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem 1.5rem;
}

.modal-title {
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

.btn-close:focus {
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.15);
}

/* --------------------------------------------------------------------------
   Spinner
   -------------------------------------------------------------------------- */
.spinner-border {
  color: var(--color-accent);
}

.text-primary .spinner-border,
.btn-primary .spinner-border {
  color: var(--color-on-accent);
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.text-primary {
  color: var(--color-accent) !important;
}

.text-accent {
  color: var(--color-accent) !important;
}

.bg-accent {
  background-color: var(--color-accent) !important;
}

.bg-elevated {
  background-color: var(--color-bg-elevated) !important;
}

.border-accent {
  border-color: var(--color-accent) !important;
}

.gradient-text {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Monospace text */
.font-mono {
  font-family: var(--font-mono);
}

/* Shadow utilities */
.shadow-glow {
  box-shadow: var(--shadow-glow);
}

/* --------------------------------------------------------------------------
   Chat Page
   -------------------------------------------------------------------------- */

/* Empty state styling */
.chat-empty-state {
  padding: 1.5rem 1rem;
}

.chat-empty-icon {
  width: 48px;
  height: 48px;
  background: var(--gradient-accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  box-shadow: 0 6px 20px rgba(0, 184, 148, 0.2);
}

.chat-empty-icon i {
  font-size: 1.25rem;
  color: var(--color-on-accent);
}

.chat-empty-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.125rem;
  text-wrap: balance;
}

.chat-empty-subtitle {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Chat starter buttons */
.chat-starters-section {
  max-width: 560px;
  margin: 0 auto;
}

.chat-starters-label {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  margin-bottom: 0.625rem;
}

.chat-starters-label i {
  color: var(--color-accent);
  font-size: 0.9rem;
}

.chat-starter-btn {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 1rem;
  text-align: left;
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background-color var(--transition-base), border-color var(--transition-base), transform var(--transition-base), color var(--transition-base);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.chat-starter-btn:hover,
.chat-starter-btn:focus {
  background: rgba(0, 184, 148, 0.08);
  border-color: var(--color-accent);
  color: var(--color-text);
  transform: translateX(4px);
}

.chat-starter-btn:active {
  transform: scale(0.96);
}

.chat-starter-btn i {
  color: var(--color-accent);
  font-size: 1.1rem;
  transition: transform var(--transition-base);
}

.chat-starter-btn:hover i {
  transform: translateX(2px);
}

/* Staggered animation for chat starters */
.chat-starters-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-starters-list .chat-starter-btn {
  opacity: 0;
  animation: chatStarterSlideIn 0.4s ease forwards;
}

.chat-starters-list .chat-starter-btn:nth-child(1) { animation-delay: 0.1s; }
.chat-starters-list .chat-starter-btn:nth-child(2) { animation-delay: 0.2s; }
.chat-starters-list .chat-starter-btn:nth-child(3) { animation-delay: 0.3s; }
.chat-starters-list .chat-starter-btn:nth-child(4) { animation-delay: 0.4s; }
.chat-starters-list .chat-starter-btn:nth-child(5) { animation-delay: 0.5s; }

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

/* Chat page: override <main> container to allow full-height layout */
main.container:has(.chat-page) {
  max-width: 100% !important;
  padding: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Hide footer on chat pages */
body:has(.chat-page) .app-footer {
  display: none !important;
}

/* When empty, center the empty state vertically */
.chat-messages:has(.chat-empty-state) {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Processing / Loading States
   -------------------------------------------------------------------------- */

/* Page navigation progress bar (HTMX boost) */
#nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--gradient-accent);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.5), 0 0 3px rgba(0, 168, 204, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  #nav-progress {
    transition: none !important;
  }
}

/* Processing message bubble */
.message-processing {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  animation: processingPulse 2s ease-in-out infinite;
}

@keyframes processingPulse {
  0%, 100% { 
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0, 184, 148, 0.1);
  }
  50% { 
    opacity: 0.85;
    box-shadow: 0 4px 16px rgba(0, 184, 148, 0.2);
  }
}

/* Typing dots animation */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--color-accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Processing text */
.processing-text {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Shimmer effect for processing */
.processing-shimmer {
  position: relative;
  overflow: hidden;
}

.processing-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 184, 148, 0.1) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* AI thinking indicator */
.ai-thinking-icon {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Product Tour Coachmark (floating popover + ambient scrim)
   -------------------------------------------------------------------------- */

.coachmark-root {
  /* Grouping container — both scrim and popover are fixed siblings. */
}

.coachmark-launcher {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1021;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 10px 28px -12px rgba(15, 23, 42, 0.45),
    0 0 0 1px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base);
}

.coachmark-launcher:hover,
.coachmark-launcher:focus-visible {
  transform: scale(1.08);
  box-shadow:
    0 14px 34px -12px rgba(0, 184, 148, 0.4),
    0 0 0 1px rgba(0, 184, 148, 0.18);
  outline: none;
}

.coachmark-launcher:focus-visible {
  box-shadow:
    0 14px 34px -12px rgba(0, 184, 148, 0.4),
    0 0 0 1px rgba(0, 184, 148, 0.18),
    0 0 0 4px rgba(0, 184, 148, 0.18);
}

.coachmark-launcher-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 0 rgba(0, 184, 148, 0.55);
  animation: coachmarkDotPulse 2.1s ease-out infinite;
}

.coachmark-scrim {
  position: fixed;
  inset: 0;
  z-index: 1020;
  pointer-events: none; /* Visual dim only — page stays interactive. */
  background:
    radial-gradient(
      ellipse 60% 55% at calc(100% - 12rem) calc(100% - 11rem),
      rgba(0, 184, 148, 0.08) 0%,
      rgba(15, 23, 42, 0) 55%
    ),
    linear-gradient(
      180deg,
      rgba(15, 23, 42, 0.08) 0%,
      rgba(15, 23, 42, 0.22) 100%
    );
  backdrop-filter: saturate(0.92) blur(0.5px);
  -webkit-backdrop-filter: saturate(0.92) blur(0.5px);
  animation: coachmarkScrimFade 600ms ease-out both;
}

.coachmark {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1021;
  width: min(420px, calc(100vw - 3rem));
  display: flex;
  gap: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 32px 60px -20px rgba(0, 168, 140, 0.28),
    0 18px 40px -18px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  isolation: isolate;
  pointer-events: auto;
  animation: coachmarkPopIn 520ms cubic-bezier(0.22, 0.9, 0.32, 1) both;
}

.coachmark::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 3.5rem;
  height: 3.5rem;
  border-top: 1px solid rgba(0, 184, 148, 0.55);
  border-left: 1px solid rgba(0, 184, 148, 0.55);
  border-top-left-radius: var(--radius-lg);
  pointer-events: none;
  z-index: 2;
  opacity: 0.85;
}

.coachmark::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle at calc(100% - 1rem) -20%,
      rgba(0, 184, 148, 0.10),
      transparent 60%
    ),
    radial-gradient(
      circle at 20% 120%,
      rgba(0, 168, 204, 0.08),
      transparent 55%
    );
  z-index: 0;
}

.coachmark-rail {
  position: relative;
  flex: 0 0 6px;
  background: linear-gradient(
    180deg,
    #00b894 0%,
    #00a8cc 52%,
    #00b894 100%
  );
  background-size: 100% 220%;
  overflow: hidden;
  z-index: 1;
  animation: coachmarkRailDrift 9s ease-in-out infinite;
}

.coachmark-rail::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.65) 0%,
    rgba(255, 255, 255, 0) 40%
  );
  opacity: 0.5;
  pointer-events: none;
}

.coachmark-rail-shine {
  position: absolute;
  left: -50%;
  right: -50%;
  top: -30%;
  height: 30%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.85) 50%,
    transparent 100%
  );
  filter: blur(2px);
  animation: coachmarkRailShine 4.2s ease-in-out infinite;
}

.coachmark-inner {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  padding: 1.5rem 1.75rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.coachmark-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.coachmark-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.coachmark-kicker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 0 rgba(0, 184, 148, 0.55);
  animation: coachmarkDotPulse 2.1s ease-out infinite;
}

.coachmark-kicker-text {
  position: relative;
  top: 1px;
}

.coachmark-close {
  appearance: none;
  border: 0;
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--transition-base),
    color var(--transition-base),
    transform var(--transition-base);
}

.coachmark-close:hover,
.coachmark-close:focus-visible {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  outline: none;
}

.coachmark-close:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.2);
}

.coachmark-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 1.05rem + 0.6vw, 1.5rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--color-text);
  max-width: 56ch;
}

.coachmark-lede {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--color-text);
  max-width: 66ch;
}

.coachmark-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.25rem;
  padding-top: 0.875rem;
  border-top: 1px dashed rgba(0, 184, 148, 0.2);
}

.coachmark-cta {
  appearance: none;
  border: 0;
  background: var(--gradient-accent);
  color: var(--color-on-accent);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 6px 18px -4px rgba(0, 184, 148, 0.45);
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base),
    filter var(--transition-base);
}

.coachmark-cta i {
  transition: transform var(--transition-base);
}

.coachmark-cta:hover,
.coachmark-cta:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 24px -6px rgba(0, 184, 148, 0.55);
  outline: none;
}

.coachmark-cta:hover i,
.coachmark-cta:focus-visible i {
  transform: translateX(3px);
}

.coachmark-cta:focus-visible {
  box-shadow:
    0 10px 24px -6px rgba(0, 184, 148, 0.55),
    0 0 0 3px rgba(0, 184, 148, 0.25);
}

.coachmark-cta:active {
  transform: translateY(0);
}

@keyframes coachmarkPopIn {
  0% {
    opacity: 0;
    transform: translate(16px, 20px) scale(0.97);
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes coachmarkScrimFade {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

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

@keyframes coachmarkRailShine {
  0%   { top: -40%; opacity: 0; }
  20%  { opacity: 0.9; }
  80%  { opacity: 0.9; }
  100% { top: 130%; opacity: 0; }
}

@keyframes coachmarkDotPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 184, 148, 0.55);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 184, 148, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 184, 148, 0);
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coachmark,
  .coachmark-scrim,
  .coachmark-launcher,
  .coachmark-launcher-dot,
  .coachmark-rail,
  .coachmark-rail-shine,
  .coachmark-kicker-dot,
  .coachmark-cta,
  .coachmark-cta i {
    animation: none !important;
    transition: none !important;
  }
}

/* Mobile: full-width bottom sheet pinned to the viewport edge, rounded only
   on top, respects iOS home-indicator safe area. Scrim stays for focus. */
@media (max-width: 640px) {
  .coachmark-scrim {
    background:
      radial-gradient(
        ellipse 90% 45% at 50% 100%,
        rgba(0, 184, 148, 0.10) 0%,
        rgba(15, 23, 42, 0) 55%
      ),
      linear-gradient(
        180deg,
        rgba(15, 23, 42, 0.06) 0%,
        rgba(15, 23, 42, 0.28) 100%
      );
  }

  .coachmark {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow:
      0 -1px 2px rgba(15, 23, 42, 0.04),
      0 -20px 48px -16px rgba(0, 168, 140, 0.32);
    animation: coachmarkSheetUp 460ms cubic-bezier(0.22, 0.9, 0.32, 1) both;
  }

  .coachmark::before {
    /* Corner bracket scales up for the wider sheet. */
    width: 4rem;
    height: 4rem;
  }

  .coachmark-rail {
    flex: 0 0 5px;
  }

  .coachmark-inner {
    padding:
      1.25rem
      1.25rem
      calc(1.25rem + env(safe-area-inset-bottom, 0px))
      1.5rem;
    gap: 0.75rem;
    overflow-y: auto;
  }

  .coachmark-title {
    font-size: 1.25rem;
  }

  .coachmark-lede {
    font-size: 0.95rem;
  }

  .coachmark-cta {
    width: 100%;
    justify-content: center;
    padding: 0.7rem 1.15rem;
  }

  .coachmark-launcher {
    right: 1.25rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes coachmarkSheetUp {
  0%   { opacity: 0; transform: translateY(100%); }
  100% { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
footer,
.app-footer {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  margin-top: auto;
}

footer a,
.app-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-base);
}

footer a:hover,
.app-footer a:hover {
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .card-body {
    padding: 1rem;
  }
  
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
  }
  
  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
  h5 { font-size: 1rem; }
}

@media (max-width: 576px) {
  .badge {
    font-size: 0.7rem;
    padding: 0.35em 0.65em;
  }
}
