/* ================================================================
   trigger-awareness.css
   Trigger Awareness section + Pattern Analysis panel
   Depends on: cravings.css design tokens (--ct-*)
================================================================ */

/* ── Trigger panel container ──────────────────────────────────── */
.ct-trigger-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px 22px;
  /* inherits ct-glass-panel border/bg/radius from existing class */
}

/* ── Panel header ─────────────────────────────────────────────── */
.ct-trigger-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.ct-trigger-panel__title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ct-trigger-panel__icon {
  font-size: 18px;
  line-height: 1;
}

.ct-trigger-panel__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.ct-trigger-panel__sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.ct-trigger-panel__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Header buttons ───────────────────────────────────────────── */
.ct-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--ct-radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  white-space: nowrap;
}

.ct-trigger-btn:active {
  transform: scale(0.97);
}

/* Add Trigger  -  teal variant */
.ct-trigger-btn--add {
  background: var(--ct-cyan-dim);
  border-color: rgba(34, 211, 238, 0.35);
  color: var(--ct-cyan);
}

.ct-trigger-btn--add:hover {
  background: rgba(34, 211, 238, 0.2);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.18);
}

/* Analyse Patterns  -  amber variant with pulse glow */
.ct-trigger-btn--analyse {
  background: var(--ct-amber-dim);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--ct-amber);
  position: relative;
  overflow: hidden;
}

.ct-trigger-btn--analyse::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: transparent;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: ct-analyse-pulse 2.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ct-analyse-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3); }
  50%      { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
}

.ct-trigger-btn--analyse:hover {
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.22);
}

.ct-trigger-btn__glyph {
  font-size: 10px;
  opacity: 0.85;
}

/* ── Sub-section wrapper ──────────────────────────────────────── */
.ct-trigger-sub {
  padding: 14px 0 0;
}

.ct-trigger-sub + .ct-trigger-sub {
  border-top: 1px solid var(--ct-glass-border);
  margin-top: 14px;
}

.ct-trigger-sub__label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Toggle button for archived section */
.ct-trigger-sub__toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 100%;
  text-align: left;
  margin-bottom: 0;
  transition: color 0.15s;
}

.ct-trigger-sub__toggle:hover {
  color: var(--text-primary);
}

.ct-trigger-sub__chevron {
  margin-left: auto;
  transition: transform 0.22s ease;
  flex-shrink: 0;
}

.ct-trigger-sub__toggle[aria-expanded="true"] .ct-trigger-sub__chevron {
  transform: rotate(180deg);
}

.ct-trigger-archived-body {
  margin-top: 12px;
}

/* Status dot */
.ct-trigger-sub__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ct-trigger-sub__dot--active {
  background: var(--ct-cyan);
  box-shadow: 0 0 6px rgba(34, 211, 238, 0.6);
}

.ct-trigger-sub__dot--archived {
  background: var(--text-secondary);
  opacity: 0.5;
}

.ct-trigger-sub__count {
  background: rgba(255,255,255,0.07);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

/* ── Trigger pill grid ────────────────────────────────────────── */
.ct-trigger-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Individual trigger pill ──────────────────────────────────── */
.ct-trigger-pill {
  position: relative;
  display: flex;
  align-items: stretch;
  background: rgba(20, 21, 48, 0.55);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  overflow: visible;
  width: calc(50% - 5px);   /* two columns */
  min-width: 180px;
  cursor: default;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ct-trigger-pill:hover {
  transform: scale(1.018);
}

/* Category accent strip  -  left border */
.ct-trigger-pill__strip {
  width: 3px;
  flex-shrink: 0;
  border-radius: 14px 0 0 14px;
  background: var(--ct-cyan);  /* overridden per category by JS */
}

/* Category colour map  -  applied via data attribute */
.ct-trigger-pill[data-category="emotional"] .ct-trigger-pill__strip,
.ct-trigger-pill[data-category="emotional"]:hover {
  --pill-accent: var(--ct-amber);
}
.ct-trigger-pill[data-category="situational"] .ct-trigger-pill__strip {
  background: var(--ct-cyan);
}
.ct-trigger-pill[data-category="emotional"] .ct-trigger-pill__strip {
  background: var(--ct-amber);
}
.ct-trigger-pill[data-category="physical"] .ct-trigger-pill__strip {
  background: #A78BFA;  /* soft violet */
}
.ct-trigger-pill[data-category="thought"] .ct-trigger-pill__strip {
  background: #64748B;  /* blue-grey */
}
.ct-trigger-pill[data-category="other"] .ct-trigger-pill__strip {
  background: var(--ct-violet);
}

/* Hover glow per category */
.ct-trigger-pill[data-category="emotional"]:hover {
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.15);
}
.ct-trigger-pill[data-category="situational"]:hover {
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
}
.ct-trigger-pill[data-category="physical"]:hover {
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.15);
}
.ct-trigger-pill[data-category="thought"]:hover {
  box-shadow: 0 0 12px rgba(100, 116, 139, 0.15);
}
.ct-trigger-pill[data-category="other"]:hover {
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.2);
}

/* Archived pill  -  desaturated */
.ct-trigger-pill--archived {
  opacity: 0.6;
  filter: saturate(0.4);
}

.ct-trigger-pill--archived:hover {
  opacity: 0.8;
  filter: saturate(0.6);
}

/* Pill body */
.ct-trigger-pill__body {
  flex: 1;
  padding: 10px 10px 10px 10px;
  min-width: 0;
}

.ct-trigger-pill__icon {
  font-size: 14px;
  margin-bottom: 2px;
  display: block;
}

.ct-trigger-pill__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.ct-trigger-pill__meta {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 3px;
  display: block;
}

.ct-trigger-pill__archived-date {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 3px;
  display: block;
  font-style: italic;
}

/* Menu button */
.ct-trigger-pill__menu-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 10px;
  font-size: 15px;
  line-height: 1;
  border-radius: 0 14px 0 0;
  transition: color 0.12s, background 0.12s;
}

.ct-trigger-pill__menu-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

/* Dropdown menu */ /* ── Trigger pill dropdown menu ───────────────────────────────── */
.ct-trigger-pill__dropdown {
  position: absolute;
  top: 36px;
  right: 8px;
  z-index: 600;
  background: #14152F;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  min-width: 148px;
  padding: 4px;
  display: none;
  flex-direction: column;
  animation: ct-dropdown-in 0.15s ease both;
}

.ct-trigger-pill__dropdown.is-open {
  display: flex;
}

@keyframes ct-dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ct-trigger-pill__dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}

.ct-trigger-pill__dropdown-item:hover {
  background: rgba(255,255,255,0.07);
}

.ct-trigger-pill__dropdown-item--danger {
  color: var(--ct-red);
}

.ct-trigger-pill__dropdown-item--danger:hover {
  background: var(--ct-red-dim);
}

/* ── Pill enter / exit animation ─────────────────────────────── */
@keyframes ct-pill-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ct-pill-archive {
  0%   { opacity: 1; transform: scale(1); }
  60%  { opacity: 0.3; transform: scale(0.93) translateY(4px); }
  100% { opacity: 0; transform: scale(0.9) translateY(8px); }
}

.ct-trigger-pill {
  animation: ct-pill-in 0.22s cubic-bezier(0.22,1,0.36,1) both;
}

.ct-trigger-pill.is-archiving {
  animation: ct-pill-archive 0.3s ease forwards;
  pointer-events: none;
}

/* Amber pulse on a specific pill (linked from analysis panel) */
@keyframes ct-pill-highlight {
  0%,100% { box-shadow: none; }
  40%     { box-shadow: 0 0 0 3px rgba(245,158,11,0.5); }
}

.ct-trigger-pill.is-highlighted {
  animation: ct-pill-highlight 1.6s ease 2;
}

/* ── Empty state ──────────────────────────────────────────────── */
.ct-trigger-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px;
  text-align: center;
  gap: 8px;
}

.ct-trigger-empty__icon {
  font-size: 28px;
  opacity: 0.7;
}

.ct-trigger-empty__msg {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 340px;
  margin: 0;
}

.ct-trigger-empty__msg--muted {
  opacity: 0.6;
}

/* ================================================================
   ADD TRIGGER DIALOG  - restyled to match craving-detail pattern
================================================================ */

/* - Backdrop - */
.ct-add-trigger-dialog::backdrop {
  background: rgba(5, 6, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* - Dialog shell - */
.ct-add-trigger-dialog {
  padding: 0;
  border: 1px solid rgba(108, 99, 255, 0.30);
  border-radius: 24px;
  background: rgba(12, 13, 35, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: var(--text-primary);
  max-width: 520px;
  width: min(520px, calc(100vw - 32px));
  max-height: 90vh;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(108, 99, 255, 0.15),
    0 0 40px rgba(108, 99, 255, 0.12),
    0 24px 64px rgba(0, 0, 0, 0.60);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.22s ease;
}
.ct-add-trigger-dialog[open] {
  display: flex;
  flex-direction: column;
  transform: translateY(0) scale(1);
}

/* - Header - */
.ct-add-trigger-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.ct-add-trigger-dialog__title-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.ct-add-trigger-dialog__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg,
                     rgba(108, 99, 255, 0.15),
                     rgba(34, 211, 238, 0.10));
  border: 1px solid rgba(108, 99, 255, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(108, 99, 255, 0.15);
}

.ct-add-trigger-dialog__title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 2px;
}

.ct-add-trigger-dialog__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.ct-add-trigger-dialog__subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.ct-add-trigger-dialog__close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}
.ct-add-trigger-dialog__close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

/* - Scrollable body - */
.ct-add-trigger-dialog__body {
  padding: 6px 24px 4px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(108, 99, 255, 0.25) transparent;
}
.ct-add-trigger-dialog__body::-webkit-scrollbar { width: 4px; }
.ct-add-trigger-dialog__body::-webkit-scrollbar-track { background: transparent; }
.ct-add-trigger-dialog__body::-webkit-scrollbar-thumb {
  background: rgba(108, 99, 255, 0.30);
  border-radius: 2px;
}

/* - Sections - */
.ct-add-trigger-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.ct-add-trigger-section:last-of-type {
  border-bottom: none;
}

.ct-add-trigger-section__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ct-add-trigger-section--notes {
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-left: 3px solid var(--ct-amber);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 4px;
}
.ct-add-trigger-section--notes .ct-add-trigger-section__title {
  color: var(--ct-amber);
  border-color: rgba(245, 158, 11, 0.12);
}
.ct-add-trigger-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.22);
  font-size: 0.72rem;
}

/* - Text input - */
.ct-add-trigger-dialog__input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--ct-radius-input, 14px);
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 10px 14px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ct-add-trigger-dialog__input:focus {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
}
.ct-add-trigger-dialog__input::placeholder { color: rgba(255,255,255,0.22); }

/* - Textarea - */
.ct-add-trigger-dialog__textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(245, 158, 11, 0.20);
  border-radius: var(--ct-radius-input, 14px);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  padding: 10px 14px;
  box-sizing: border-box;
  resize: vertical;
  outline: none;
  min-height: 80px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ct-add-trigger-dialog__textarea:focus {
  border-color: rgba(245, 158, 11, 0.50);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08);
}
.ct-add-trigger-dialog__textarea::placeholder { color: rgba(255,255,255,0.22); }

/* - Category pill buttons - */
.ct-trigger-cat-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.ct-trigger-cat-custom { margin-top: 10px; }

.ct-trigger-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s;
}
.ct-trigger-cat-btn.is-selected {
  background: rgba(108, 99, 255, 0.18);
  border-color: rgba(108, 99, 255, 0.50);
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(108, 99, 255, 0.15);
}
.ct-trigger-cat-btn:hover:not(.is-selected) {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

/* - Char counter - */
.ct-char-count {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.22);
  text-align: right;
  display: block;
}

/* - Error - */
.ct-add-trigger-dialog__error {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ct-red, #F87171);
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.20);
  border-radius: 10px;
  padding: 8px 12px;
}
.ct-add-trigger-dialog__error[hidden] { display: none; }

/* - Footer - */
.ct-add-trigger-dialog__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.ct-add-trigger-footer-btn {
  flex: 1;
  padding: 11px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.2s ease;
}
.ct-add-trigger-footer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.ct-add-trigger-footer-btn--save {
  background: rgba(108, 99, 255, 0.18);
  border-color: rgba(108, 99, 255, 0.40);
  color: #fff;
}
.ct-add-trigger-footer-btn--save:hover {
  background: rgba(108, 99, 255, 0.28);
  box-shadow: 0 0 18px rgba(108, 99, 255, 0.25);
  border-color: rgba(108, 99, 255, 0.55);
}

/* - Mobile - */
@media (max-width: 480px) {
  .ct-add-trigger-dialog__header { padding: 18px 16px 14px; }
  .ct-add-trigger-dialog__body { padding: 4px 16px 4px; }
  .ct-add-trigger-dialog__footer { padding: 12px 16px 18px; }
  .ct-add-trigger-footer-btn { font-size: 0.82rem; padding: 10px 12px; }
}

/* ── Pattern Analysis panel ───────────────────────────────────── */
.ct-analysis-scrim {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(6, 7, 20, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.ct-analysis-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ct-analysis-panel {
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  width: min(720px, 92vw);
  max-height: 82vh;
  z-index: 800;
  background: var(--ct-glass-bg-hero);
  backdrop-filter: blur(var(--ct-glass-blur));
  -webkit-backdrop-filter: blur(var(--ct-glass-blur));
  border: 1px solid var(--ct-glass-border);
  border-radius: var(--ct-radius-panel);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  padding-bottom: 20px;
  box-shadow: 0 0 0 1px rgba(108, 99, 255, 0.15),
              0 0 30px rgba(108, 99, 255, 0.12),
              0 28px 70px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.ct-analysis-panel.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ── Analysis panel header ────────────────────────────────────── */
.ct-analysis-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: rgba(10, 11, 28, 0.98);
  z-index: 2;
}

.ct-analysis-panel__title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.ct-analysis-panel__pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ct-amber);
  box-shadow: 0 0 8px rgba(245,158,11,0.7);
  flex-shrink: 0;
  animation: ct-analyse-pulse 2.5s ease-in-out infinite;
}

.ct-analysis-panel__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ct-analysis-panel__meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
  flex-shrink: 0;
}

.ct-analysis-panel__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.ct-analysis-panel__close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.07);
}

/* ── Analysis cards ───────────────────────────────────────────── */
.ct-analysis-card {
  margin: 14px 16px 0;
  background: rgba(20, 21, 48, 0.6);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 0 0 1px rgba(108, 99, 255, 0.12),
              0 0 18px rgba(108, 99, 255, 0.14);
}

/* Card 1  -  narrative */
.ct-analysis-card--narrative {
  min-height: 180px;
}

.ct-analysis-narrative {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.ct-analysis-card--narrative.is-done {
  min-height: 0;
}

/* Blinking cursor during typewriter */
.ct-analysis-narrative::after {
  content: '|';
  display: inline;
  color: var(--ct-amber);
  animation: ct-cursor-blink 0.9s step-start infinite;
  margin-left: 1px;
}

.ct-analysis-narrative.is-done::after {
  display: none;
}

@keyframes ct-cursor-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* Skeleton loader */
.ct-analysis-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ct-analysis-skeleton__line {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: ct-skeleton-shimmer 1.6s infinite;
  width: 100%;
}

.ct-analysis-skeleton__line--short { width: 55%; }
.ct-analysis-skeleton__line--med   { width: 75%; }

@keyframes ct-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Card 2  -  chips */
.ct-analysis-chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ct-analysis-chip {
  flex: 1 1 calc(50% - 5px);
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 10px 12px;
}

.ct-analysis-chip__icon {
  font-size: 14px;
}

.ct-analysis-chip__val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.ct-analysis-chip__val--trigger {
  font-size: 13px;
  color: var(--ct-amber);
}

.ct-analysis-chip__val--pct {
  color: var(--ct-green);
}

.ct-analysis-chip__val--amber { color: var(--ct-amber); }
.ct-analysis-chip__val--red   { color: var(--ct-red); }
.ct-analysis-chip__val--green { color: var(--ct-green); }

.ct-analysis-chip__label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Card 3  -  suggested actions */
.ct-analysis-card--actions {
  padding-bottom: 12px;
}

.ct-analysis-actions__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.ct-analysis-actions-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.ct-analysis-actions-row::-webkit-scrollbar { display: none; }

.ct-analysis-action-tile {
  flex: 0 0 145px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  overflow: hidden;
  transition: background 0.15s, transform 0.15s;
  cursor: default;
}

/* Left accent strip per category */
.ct-analysis-action-tile::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--tile-accent, var(--ct-cyan));
  border-radius: 14px 0 0 14px;
}

.ct-analysis-action-tile--intervention {
  border-color: rgba(108, 99, 255, 0.3);
  cursor: pointer;
}

.ct-analysis-action-tile--intervention:hover {
  background: rgba(108, 99, 255, 0.08);
  transform: scale(1.02);
}

.ct-analysis-action-tile__icon {
  font-size: 18px;
}

.ct-analysis-action-tile__headline {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.ct-analysis-action-tile__sub {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.ct-analysis-action-tile__cta {
  font-size: 10px;
  font-weight: 700;
  color: var(--ct-violet);
  margin-top: auto;
  padding-top: 4px;
}

/* ── Trigger detail popout ──────────────────────────────────── */
.ct-trigger-detail-scrim {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(6, 7, 20, 0.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.ct-trigger-detail-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ct-trigger-detail-panel {
  position: fixed;
  z-index: 901;
  width: min(560px, 92vw);
  max-height: 80vh;
  top: 50%;
  left: 50%;
  background: var(--ct-glass-bg-hero);
  border: 1px solid var(--ct-glass-border);
  border-radius: var(--ct-radius-panel);
  box-shadow: 0 0 0 1px rgba(108, 99, 255, 0.15),
              0 0 30px rgba(108, 99, 255, 0.12),
              0 28px 70px rgba(0,0,0,0.65);
  backdrop-filter: blur(var(--ct-glass-blur));
  -webkit-backdrop-filter: blur(var(--ct-glass-blur));
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  overflow: hidden;
}
.ct-trigger-detail-panel.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.ct-trigger-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ct-trigger-detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ct-trigger-detail-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(108, 99, 255, 0.16);
  border: 1px solid rgba(108, 99, 255, 0.35);
  color: #c4b8ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.2);
}
.ct-trigger-detail-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.ct-trigger-detail-sub {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}
.ct-trigger-detail-close {
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ct-trigger-detail-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}

.ct-trigger-detail-body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: 60vh;
}
.ct-trigger-detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ct-trigger-detail-metric {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ct-trigger-detail-metric .v {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.ct-trigger-detail-metric .k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45);
}
.ct-trigger-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ct-trigger-detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--ct-radius-pill);
  font-size: 11px;
  font-weight: 600;
  color: #c7c9ff;
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.25);
}
.ct-trigger-detail-chip--cat {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.25);
  color: #7fe7f7;
}
.ct-trigger-detail-section {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 12px 14px;
}
.ct-trigger-detail-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
  margin-bottom: 10px;
}
.ct-trigger-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ct-trigger-detail-row:last-child {
  border-bottom: none;
}
.ct-trigger-detail-row .k {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ct-trigger-detail-row .v {
  color: var(--text-primary);
}
.ct-trigger-detail-note {
  font-size: 12px;
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.5;
}
.ct-trigger-detail-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  font-style: italic;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ct-trigger-pill {
    width: 100%;
    min-width: 0;
  }

  .ct-trigger-panel__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ct-trigger-panel__actions {
    width: 100%;
  }

  .ct-trigger-btn--add,
  .ct-trigger-btn--analyse {
    flex: 1;
    justify-content: center;
  }

  /* Analysis panel  -  centered modal on mobile */
  .ct-analysis-panel {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: 92vw;
    max-width: 92vw;
    max-height: 84vh;
    border-left: 1px solid rgba(245, 158, 11, 0.25);
    border-top: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 20px;
    transform: translate(-50%, -50%) scale(0.96);
  }

  .ct-analysis-panel.is-open {
    transform: translate(-50%, -50%) scale(1);
  }

  .ct-trigger-detail-panel {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: 92vw;
    max-width: 92vw;
    max-height: 80vh;
  }

  .ct-trigger-detail-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .ct-analysis-chip {
    flex: 1 1 calc(50% - 5px);
  }

  .ct-analysis-card {
    margin: 10px 12px 0;
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ct-trigger-btn--analyse::before,
  .ct-analysis-panel__pulse,
  .ct-analysis-narrative::after,
  .ct-analysis-skeleton__line,
  .ct-trigger-pill {
    animation: none;
  }
  .ct-analysis-panel,
  .ct-analysis-scrim {
    transition: none;
  }
}
