/* Erika Design System — Copyright (c) 2026 Simon Sanladerer
   The visual design, composition, layout patterns, token values, and
   individual styles in this file are protected creative work.
   Licensed under the Elastic License 2.0 — see LICENSE in this directory. */

/* ================================================================
   Erika Components — Reusable UI Component Styles
   ================================================================
   All stage HTML files import this file via:
     <link rel="stylesheet" href="../styles/components.css">

   Requires: shared/layout.css (design tokens, reset, grid utilities)

   Contents:
     - Card (.card, --compact, --flush, --row)
     - Button (.btn, variants, sizes, states)
     - Input (.input, .textarea, .input-group)
     - Badge (.badge, variants, sizes)
     - Session Card (.session-card, states)
     - Toast (.toast, variants, stacking)
     - App Header (.app-header, nav, avatar)
     - Search Bar (.search-bar, states)
     - Upload Zone (.upload-zone, states)
     - Section Header (.section-header, marker/detected)
     - Modal Shell (.modal, overlay, header/body/footer)
     - Empty State (.empty-state)
     - Skeleton Loader (.skeleton, variants)
     - Spinners & Loaders (.spinner, .dot-spinner, .bar-loader,
       .progress-bar, .pulse-spinner, .matrix-loader)
     - Dropdown / Select (.dropdown, menu, options)
     - Date Input (.date-input, states)
     - Email Input (.email-input-wrap, validation)
     - Terminal Chrome (.terminal-chrome, titlebar, body)
     - Breadcrumb (.breadcrumb, links, separator)
     - Prev/Next Nav (.nav-arrows, .nav-arrow)
     - Filter Pills (.filter-pills, .filter-pill)
     - Session Viewer Composition (.session-viewer, glue styles)

   ================================================================ */

/* ======================
   ANIMATION: TRON BORDER TRAIL
   ======================
   Animated conic-gradient that rotates around focused inputs,
   dropdowns, and upload zones — creating a TRON light-cycle
   trail effect on the element perimeter.

   Uses @property for animatable CSS custom property.
   Applied via border-box/padding-box background layering on :focus states.
   ====================== */
@property --border-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes border-rotate {
  from { --border-angle: 0deg; }
  to   { --border-angle: 360deg; }
}

/* Trail dot — travels along the rectangular border at constant speed */
@keyframes tron-trail {
  0%   { offset-distance: 0%; }
  100% { offset-distance: 100%; }
}

/* Trail wrapper — wraps any bordered element that needs the TRON trail.
   The trail dot travels along the element's rectangular border at constant speed.
   Apply .tron-trail around: <input>, <textarea>, .search-bar__input,
   .dropdown__trigger, .upload-zone */
.tron-trail {
  position: relative;
  display: block;
}

.tron-trail:focus-within::before,
.tron-trail--active::before,
.search-bar:focus-within::before,
.dropdown--open::before,
.upload-zone--drag-over::before {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px 2px var(--accent-primary-glow),
              0 0 20px 4px rgba(0, 212, 255, 0.3);
  offset-path: rect(0% 100% 100% 0% round var(--radius-lg));
  animation: tron-trail 4s linear infinite;
  z-index: 10;
  pointer-events: none;
}

/* Error variant — red trail */
.tron-trail--error:focus-within::before {
  background: var(--status-error);
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--status-error) 40%, transparent),
              0 0 20px 4px color-mix(in srgb, var(--status-error) 30%, transparent);
}

/* Valid variant — green trail */
.tron-trail--valid:focus-within::before {
  background: var(--status-success);
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--status-success) 40%, transparent),
              0 0 20px 4px color-mix(in srgb, var(--status-success) 30%, transparent);
}

/* Dropdown uses --radius-md */
.tron-trail--dropdown:focus-within::before,
.tron-trail--dropdown.tron-trail--active::before,
.dropdown--open::before {
  offset-path: rect(0% 100% 100% 0% round var(--radius-md));
}

/* ======================
   BASE: CARD
   ======================
   Reusable card foundation. Use alone or extend with modifiers.
   .card                — default (column layout, space-5 padding, radius-xl)
   .card--compact       — tighter padding (space-3 / space-4) and radius-lg
   .card--flush         — zero padding, overflow hidden (for full-bleed content)
   .card--row           — horizontal layout
   ====================== */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--rhythm-half);
  padding: var(--rhythm-1);
  background: rgba(10, 10, 25, 0.55);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6),
              0 0 8px rgba(0, 212, 255, 0.15),
              inset 0 0 8px rgba(0, 212, 255, 0.05);
}

.card--compact {
  padding: var(--rhythm-half) var(--space-4);
  gap: var(--space-1);
  border-radius: var(--radius-lg);
}

.card--flush {
  padding: 0;

  overflow: hidden;
}

.card--row {
  flex-direction: row;
  align-items: center;
  gap: var(--space-5);
}

/* --- Card children --- */
.card__media {
  width: 100%;
  display: block;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--rhythm-half);
}

.card--row .card__body {
  padding: 0;
}

.card__body--right {
  flex-shrink: 0;
  min-width: var(--progress-width);
  text-align: right;
}

.card__body--compact-right {
  flex-shrink: 0;
  text-align: right;
}

.card__title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.card__label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.card__value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.card__value--break {
  word-break: break-all;
}

.card__desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ======================
   COMPONENT: BUTTON
   ====================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-default);
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  white-space: nowrap;
}

/* TRON trail on hover and focus — uses border-color which stays semantic */
.btn:hover::before,
.btn:focus-visible::before {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px 2px var(--accent-primary-glow),
              0 0 20px 4px rgba(0, 212, 255, 0.3);
  offset-path: rect(0% 100% 100% 0% round var(--radius-md));
  animation: tron-trail 4s linear infinite;
  z-index: 10;
  pointer-events: none;
}

.btn:focus-visible {
  outline: none;
}

/* Disabled buttons must not show TRON trail */
.btn--primary-disabled:hover::before,
.btn--primary-disabled:focus-visible::before,
.btn--secondary-disabled:hover::before,
.btn--secondary-disabled:focus-visible::before,
.btn--ghost-disabled:hover::before,
.btn--ghost-disabled:focus-visible::before,
.btn--destructive-disabled:hover::before,
.btn--destructive-disabled:focus-visible::before {
  display: none;
}

/* Destructive trail — red */
.btn--destructive:hover::before,
.btn--destructive:focus-visible::before {
  background: var(--status-error);
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--status-error) 40%, transparent),
              0 0 20px 4px color-mix(in srgb, var(--status-error) 30%, transparent);
}

/* Secondary trail — muted */
.btn--secondary:hover::before,
.btn--secondary:focus-visible::before {
  background: var(--text-secondary);
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--text-secondary) 40%, transparent),
              0 0 20px 4px color-mix(in srgb, var(--text-secondary) 30%, transparent);
}

/* Ghost trail — muted */
.btn--ghost:hover::before,
.btn--ghost:focus-visible::before {
  background: var(--text-secondary);
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--text-secondary) 40%, transparent),
              0 0 20px 4px color-mix(in srgb, var(--text-secondary) 30%, transparent);
}

/* Primary */
.btn--primary {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.btn--primary:hover,
.btn--primary:focus-visible,
.btn--primary-hover {
  background: rgba(0, 212, 255, 0.12);
  color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-glow),
              inset 0 0 12px rgba(0, 212, 255, 0.06);
}
.btn--primary:active,
.btn--primary-active {
  background: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
  box-shadow: none;
}
.btn--primary-disabled {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.btn--primary-loading {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  opacity: 0.65;
  cursor: wait;
}

/* Secondary */
.btn--secondary {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.btn--secondary:hover,
.btn--secondary:focus-visible,
.btn--secondary-hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: var(--bg-elevated);
}
.btn--secondary:active,
.btn--secondary-active {
  background: var(--bg-surface);
  border-color: var(--text-muted);
  color: var(--text-primary);
}
.btn--secondary-disabled {
  border-color: var(--border-default);
  color: var(--text-disabled);
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Ghost */
.btn--ghost {
  color: var(--text-secondary);
  border-color: transparent;
}
.btn--ghost:hover,
.btn--ghost:focus-visible,
.btn--ghost-hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.btn--ghost:active,
.btn--ghost-active {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.btn--ghost-disabled {
  color: var(--text-disabled);
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Destructive */
.btn--destructive {
  border-color: var(--status-error);
  color: var(--status-error);
}
.btn--destructive:hover,
.btn--destructive:focus-visible,
.btn--destructive-hover {
  background: var(--status-error);
  color: var(--text-inverse);
  border-color: var(--status-error);
  box-shadow: var(--glow-error);
}
.btn--destructive:active,
.btn--destructive-active {
  background: var(--accent-secondary);
  color: var(--text-inverse);
  border-color: var(--accent-secondary);
  box-shadow: none;
}
.btn--destructive-disabled {
  border-color: var(--status-error);
  color: var(--status-error);
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button sizes */
.btn--sm {
  height: var(--btn-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn--lg {
  height: var(--btn-height-lg);
  padding: 0 var(--space-6);
  font-size: var(--text-lg);
}

/* Loading spinner */
.btn__spinner {
  display: inline-block;
  width: var(--space-4);
  height: var(--space-4);
  border: var(--space-0\.5) solid transparent;
  border-top-color: currentColor;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

.btn--sm .btn__spinner {
  width: var(--space-3);
  height: var(--space-3);
}

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

/* ======================
   COMPONENT: INPUT
   ====================== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.input-group__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.input {
  width: 100%;
  height: var(--input-height-sm);
  padding: var(--space-1) var(--space-3);
  background: rgba(10, 10, 25, 0.55);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  letter-spacing: var(--tracking-normal);
  outline: none;
  transition: border-color var(--duration-fast) var(--easing-default),
              box-shadow var(--duration-fast) var(--easing-default);
}

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

.input:focus,
.input--focused {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 var(--space-0\.5) var(--accent-primary-subtle),
              0 0 12px var(--accent-primary-glow);
}

.input--error,
.input--error:focus {
  border-color: var(--status-error);
  box-shadow: 0 0 0 var(--space-0\.5) var(--status-error-subtle),
              0 0 12px color-mix(in srgb, var(--status-error) 40%, transparent);
}


.input--disabled,
.input:disabled {
  background: var(--bg-page);
  color: var(--text-disabled);
  border-color: var(--border-default);
  cursor: not-allowed;
}

.input-group__helper {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--lh-sm);
}

.input-group__error {
  font-size: var(--text-sm);
  color: var(--status-error);
  line-height: var(--lh-sm);
}

/* Textarea */
.textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: rgba(10, 10, 25, 0.55);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  outline: none;
  resize: vertical;
  min-height: calc(5 * var(--space-4));
  transition: border-color var(--duration-fast) var(--easing-default),
              box-shadow var(--duration-fast) var(--easing-default);
}

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

.textarea:focus,
.textarea--focused {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 var(--space-0\.5) var(--accent-primary-subtle),
              0 0 12px var(--accent-primary-glow);
}

.textarea--error,
.textarea--error:focus {
  border-color: var(--status-error);
  box-shadow: 0 0 0 var(--space-0\.5) var(--status-error-subtle),
              0 0 12px color-mix(in srgb, var(--status-error) 40%, transparent);
}


/* ======================
   COMPONENT: BADGE
   ====================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-0\.5) var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  line-height: var(--lh-base);
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}

.badge--sm {
  padding: var(--space-0\.5) var(--space-1\.5);
  font-size: var(--text-xs);
  line-height: var(--lh-base);
}

.badge--accent {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

.badge--success {
  background: var(--status-success-subtle);
  color: var(--status-success);
  border: 1px solid color-mix(in srgb, var(--status-success) 20%, transparent);
}

.badge--warning {
  background: var(--status-warning-subtle);
  color: var(--status-warning);
  border: 1px solid color-mix(in srgb, var(--status-warning) 20%, transparent);
}

.badge--error {
  background: var(--status-error-subtle);
  color: var(--status-error);
  border: 1px solid color-mix(in srgb, var(--status-error) 20%, transparent);
}

.badge--info {
  background: var(--status-info-subtle);
  color: var(--status-info);
  border: 1px solid color-mix(in srgb, var(--status-info) 20%, transparent);
}

.badge--neutral {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.badge__dot {
  width: var(--space-1\.5);
  height: var(--space-1\.5);
  border-radius: var(--radius-full);
  background: currentColor;
}

.badge--secondary {
  background: var(--accent-secondary-subtle);
  color: var(--accent-secondary);
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 20%, transparent);
}

/* ======================
   COMPONENT: SESSION CARD
   ====================== */
.session-card {
  /* Extends .card — use class="card session-card" in markup,
     or apply .card base via session-card overrides below */
  display: flex;
  flex-direction: column;
  gap: var(--rhythm-half);
  padding: var(--rhythm-half) var(--rhythm-1);
  background: rgba(10, 10, 25, 0.55);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6),
              0 0 8px rgba(0, 212, 255, 0.15),
              inset 0 0 8px rgba(0, 212, 255, 0.05);
  transition: all var(--duration-fast) var(--easing-default);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.session-card:hover,
.session-card--hover {
  border-color: rgba(0, 212, 255, 0.4);
  background: rgba(10, 10, 25, 0.85);
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7),
              0 0 14px rgba(0, 212, 255, 0.25),
              inset 0 0 12px rgba(0, 212, 255, 0.08);
}

.session-card--selected {
  border-color: var(--accent-primary);
  background: rgba(10, 10, 25, 0.85);
  box-shadow: 0 0 0 var(--space-0\.5) var(--accent-primary-subtle),
              0 0 20px rgba(0, 212, 255, 0.25);
}

.session-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.session-card__filename {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.session-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
}

.session-card__meta-item svg {
  width: var(--space-4);
  height: var(--space-4);
  color: var(--text-muted);
}

.session-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ======================
   COMPONENT: TOAST / NOTIFICATION
   ====================== */
.toast {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-radius: var(--radius-xl);
  background: rgba(10, 10, 25, 0.55);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(0, 212, 255, 0.25);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6),
              0 0 8px rgba(0, 212, 255, 0.15);
  min-width: var(--toast-min-width);
  max-width: var(--toast-max-width);
  min-height: 76px;
  overflow: hidden;
}

.toast__icon {
  flex-shrink: 0;
  width: var(--rhythm-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
}

.toast__content {
  flex: 1;
  min-width: 0;
  padding: var(--rhythm-half) var(--space-4);
  align-self: center;
}

.toast__title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-0\.5);
}

.toast__message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--lh-sm);
}

.toast__close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-5);
  height: var(--space-5);
  margin: 0 var(--space-3) 0 0;
  align-self: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--easing-default);
}

.toast__close:hover {
  color: var(--text-primary);
  background: rgba(0, 212, 255, 0.08);
}

.toast--success .toast__icon { background: var(--status-success); }
.toast--warning .toast__icon { background: var(--status-warning); }
.toast--error .toast__icon { background: var(--status-error); }
.toast--info .toast__icon { background: var(--status-info); }

.toast-stack {
  display: flex;
  flex-direction: column;
  gap: var(--rhythm-half);
}

/* ======================
   COMPONENT: APP HEADER
   ====================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  background: rgba(33, 33, 54, 0.32);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: none;
  height: var(--header-height);
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

/* Gradient bottom line — TRON light trail */
.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--accent-primary) 20%,
    var(--accent-primary) 50%,
    var(--accent-secondary) 80%,
    transparent 100%
  );
  opacity: 0.8;
  box-shadow: 0 0 12px var(--accent-primary-glow),
              0 0 24px rgba(0, 212, 255, 0.2);
}

/* Fixed positioning applied only via inline style or JS injection,
   NOT on the base class — demo headers in the component guide also
   use .app-header and must remain in normal flow. */

.app-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
  flex: 1;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-primary);
}

.app-header__logo {
  width: var(--space-8);
  height: var(--space-8);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--accent-primary);
  transition: box-shadow var(--duration-normal) var(--easing-default);
}

.app-header__brand:hover .app-header__logo {
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

.app-header__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}

.app-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.app-header__nav-link {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--easing-default);
}

.app-header__nav-link:hover,
.app-header__nav-link--hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.app-header__nav-link--active {
  color: var(--accent-primary);
}

.app-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-header__avatar {
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--easing-default),
              box-shadow var(--duration-fast) var(--easing-default);
}

.app-header__avatar:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary-glow);
}

/* --- App Header: inline nav dropdown --- */
.app-header__nav .dropdown {
  width: auto;
}

.app-header__nav .dropdown__trigger {
  background: transparent;
  border: none;
  height: var(--btn-height-sm);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-base);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.app-header__nav .dropdown__trigger:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: none;
}

.app-header__nav .dropdown__trigger--focused {
  border: none;
  box-shadow: none;
}

.app-header__nav .dropdown__menu {
  min-width: 260px;
  max-height: 70vh;
  overflow-y: scroll;
}

.app-header__nav .dropdown__menu::-webkit-scrollbar {
  width: 8px;
}

.app-header__nav .dropdown__menu::-webkit-scrollbar-track {
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  margin: var(--space-2) 0;
}

.app-header__nav .dropdown__menu::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}

.app-header__nav .dropdown__menu::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.app-header__nav .dropdown__group-label {
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.app-header__nav .dropdown__group-label:not(:first-child) {
  padding-top: var(--space-2);
}

.app-header__search {
  width: var(--progress-width);
  min-width: 0;
  flex-shrink: 1;
  margin-left: var(--space-4);
}

/* --- App Header: responsive --- */
@media (max-width: 767px) {
  .app-header {
    padding: var(--space-2) var(--space-3);
  }

  .app-header__left {
    gap: var(--space-2);
  }

  .app-header__name {
    font-size: var(--text-base);
  }

  .app-header__right {
    display: none;
  }

  .app-header__search {
    width: 0;
    flex: 1 1 80px;
    margin-left: var(--space-2);
  }

  .app-header__search .search-bar {
    height: var(--btn-height-sm);
    margin-top: var(--rhythm-quarter);
    margin-bottom: var(--rhythm-quarter);
  }

  .app-header__search .search-bar__input {
    font-size: var(--text-sm);
    height: var(--btn-height-sm);
    padding-left: var(--space-6);
    padding-right: var(--space-2);
  }

  .app-header__search .search-bar__icon {
    left: var(--space-2);
  }

  .app-header__search .search-bar__icon svg {
    width: 14px;
    height: 14px;
  }

  .app-header__nav .dropdown__trigger {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    max-width: 120px;
  }

  .app-header__nav .dropdown__trigger > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }


}

/* ======================
   COMPONENT: SEARCH BAR
   ====================== */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  /* Match input height so TRON trail follows the visible border exactly */
  height: var(--input-height-sm);
}

.search-bar__icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-bar__icon svg {
  width: var(--space-4);
  height: var(--space-4);
}

.search-bar__input {
  width: 100%;
  height: var(--input-height-sm);
  padding: 0 var(--space-3);
  padding-left: var(--space-8);
  padding-right: var(--space-8);
  background: rgba(10, 10, 25, 0.55);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  outline: none;
  transition: border-color var(--duration-fast) var(--easing-default),
              box-shadow var(--duration-fast) var(--easing-default);
}

.search-bar__input::placeholder {
  color: var(--text-muted);
}

.search-bar__input:focus,
.search-bar__input--focused {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 var(--space-0\.5) var(--accent-primary-subtle),
              0 0 12px var(--accent-primary-glow);
}

.search-bar__clear {
  position: absolute;
  right: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-5);
  height: var(--space-5);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--easing-default);
}

.search-bar__clear:hover {
  color: var(--text-primary);
}

.search-bar__clear svg {
  width: var(--space-3);
  height: var(--space-3);
}

.search-bar__count {
  position: absolute;
  right: var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
}

/* ======================
   COMPONENT: UPLOAD ZONE
   ====================== */
.upload-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-12) var(--space-8);
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: rgba(10, 10, 25, 0.41);
  backdrop-filter: blur(calc(var(--glass-blur) * 1.5));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.5));
  border: 1px solid rgba(0, 212, 255, 0.25);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6),
              0 0 8px rgba(0, 212, 255, 0.15),
              inset 0 0 8px rgba(0, 212, 255, 0.05);
  overflow: hidden;
  text-align: center;
  transition: transform var(--duration-normal) var(--easing-default),
              box-shadow var(--duration-normal) var(--easing-default),
              border-color var(--duration-normal) var(--easing-default);
}

/* Hover: lift + intensify glow */
.upload-zone:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 212, 255, 0.4);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.7),
              0 0 14px rgba(0, 212, 255, 0.25),
              inset 0 0 12px rgba(0, 212, 255, 0.08);
}

/* Focus visible ring */
.upload-zone:focus-visible {
  outline: 1px solid var(--accent-primary);
  outline-offset: var(--space-1);
}

.upload-zone__icon {
  width: 44px;
  height: 44px;
  color: var(--accent-primary);
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 8px var(--accent-primary-glow));
}

.upload-zone__icon svg {
  width: 100%;
  height: 100%;
}

/* Disc ring — thin circle around the icon */
.upload-zone__disc-ring {
  position: absolute;
  width: 72px;
  height: 72px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.upload-zone__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-2xl);
  color: var(--text-primary);
  position: relative;
  z-index: 2;
}

.upload-zone__subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--lh-base);
  max-width: 400px;
  position: relative;
  z-index: 2;
}

.upload-zone__subtitle code {
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--accent-primary-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* CTA browse button — TRON geometric style */
.upload-zone__browse {
  color: var(--accent-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-mono);
  text-decoration: none;
  cursor: pointer;
  margin-top: var(--space-2);
  position: relative;
  z-index: 2;
  padding: var(--space-2) var(--space-6);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: var(--radius-sm);
  background: transparent;
  transition: all var(--duration-fast) var(--easing-default);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.upload-zone__browse:hover {
  background: var(--accent-primary-subtle);
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.12),
              inset 0 0 16px rgba(0, 212, 255, 0.04);
}

/* Drag over */
.upload-zone--drag-over {
  border-color: rgba(0, 212, 255, 0.5);
  background: rgba(0, 212, 255, 0.06);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7),
              0 0 14px rgba(0, 212, 255, 0.25),
              inset 0 0 12px rgba(0, 212, 255, 0.08);
}

.upload-zone--drag-over .upload-zone__icon {
  color: var(--accent-primary);
}

.upload-zone--drag-over .upload-zone__title {
  color: var(--accent-primary);
}

/* Uploading */
.upload-zone--uploading {
  border-color: var(--accent-primary);
}

.upload-zone__progress {
  width: var(--progress-width);
  height: var(--space-1);
  background: var(--bg-page);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.upload-zone__progress-bar {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--easing-default);
}

/* Success */
.upload-zone--success {
  border-color: var(--status-success);
}

.upload-zone--success .upload-zone__icon {
  color: var(--status-success);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--status-success) 40%, transparent));
}

.upload-zone--success .upload-zone__disc-ring {
  border-color: color-mix(in srgb, var(--status-success) 15%, transparent);
}

/* Error */
.upload-zone--error {
  border-color: var(--status-error);
}

.upload-zone--error .upload-zone__icon {
  color: var(--status-error);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--status-error) 40%, transparent));
}

.upload-zone--error .upload-zone__disc-ring {
  border-color: color-mix(in srgb, var(--status-error) 15%, transparent);
}

/* ======================
   COMPONENT: SECTION HEADER
   ====================== */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--rhythm-half) var(--space-4);
  background: rgba(10, 10, 25, 0.55);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-default);
  user-select: none;
}

.section-header:hover,
.section-header--hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.section-header__chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-5);
  height: var(--space-5);
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--easing-default);
  flex-shrink: 0;
  transform: rotate(90deg);
}

.section-header__chevron svg {
  width: var(--space-4);
  height: var(--space-4);
}

.section-header--collapsed .section-header__chevron {
  transform: rotate(0deg);
}

.section-header__label {
  flex: 1;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.section-header__range {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
}

.section-header--detected {
  border-left: var(--space-2) solid var(--accent-primary);
}

.section-header--detected .section-header__label {
  color: var(--accent-primary);
}

.section-header--marker {
  border-left: var(--space-2) solid var(--accent-secondary);
}

.section-header--marker .section-header__label {
  color: var(--accent-secondary);
}

.section-header--collapsed {
  opacity: 0.7;
}

/* ======================
   COMPONENT: MODAL SHELL
   ====================== */

/* Fullscreen modal backdrop — covers viewport, locks scroll on html+body */
html:has(.modal-backdrop),
html:has(.modal-backdrop) body {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

/* Component showcase wrapper (non-fullscreen) */
.modal-overlay {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  min-height: 420px;   /* 20 baseline units */
}

.modal {
  background: rgba(10, 10, 25, 0.92);
  backdrop-filter: blur(calc(var(--glass-blur) * 2));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 2));
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7),
              0 0 14px rgba(0, 212, 255, 0.2),
              var(--shadow-lg);
  width: 100%;
  max-width: var(--modal-max-width);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rhythm-half) var(--rhythm-1);
  border-bottom: 1px solid var(--border-default);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-8);
  height: var(--space-8);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--easing-default);
}

.modal__close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.modal__body {
  padding: var(--rhythm-1);
  overflow-y: auto;
  flex: 1;
}

.modal:has(.dropdown--open) {
  overflow: visible;
}

.modal__body:has(.dropdown--open) {
  overflow: visible;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--rhythm-half) var(--rhythm-1);
  border-top: 1px solid var(--border-default);
}

/* ======================
   COMPONENT: EMPTY STATE
   ====================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--rhythm-2) var(--space-8);
}

.empty-state__icon {
  color: var(--text-muted);
  margin-bottom: var(--rhythm-1);
}

.empty-state__icon svg {
  width: var(--space-12);
  height: var(--space-12);
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--rhythm-half);
  letter-spacing: var(--tracking-tight);
}

.empty-state__description {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 400px;
  line-height: var(--lh-base);
  margin-bottom: var(--rhythm-1);
}

/* ======================
   COMPONENT: SKELETON LOADER
   ====================== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 212, 255, 0.04) 0%,
    rgba(0, 212, 255, 0.10) 50%,
    rgba(0, 212, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton--text {
  height: var(--space-4);
  margin-bottom: var(--space-2);
}

.skeleton--text-sm {
  height: var(--space-3);
  width: 60%;
}

.skeleton--badge {
  height: var(--space-5);
  width: 80px;
  border-radius: var(--radius-full);
}

.skeleton--card {
  padding: var(--rhythm-half) var(--rhythm-1);
  background: rgba(10, 10, 25, 0.55);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--rhythm-half);
}

/* .skeleton--card .skeleton — no override needed.
   Base .skeleton uses relative rgba overlays that adapt to any parent background. */

.skeleton--card-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ======================
   COMPONENT: SPINNERS & LOADERS
   ====================== */

/* --- Ring Spinner (sm / md / lg) --- */
.spinner {
  display: inline-block;
  border: var(--space-0\.5) solid var(--border-strong);
  border-top-color: var(--accent-primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner--sm {
  width: var(--space-4);
  height: var(--space-4);
}

.spinner--md {
  width: var(--space-8);
  height: var(--space-8);
  border-width: var(--space-0\.5);
}

.spinner--lg {
  width: var(--space-12);
  height: var(--space-12);
  border-width: var(--space-1);
}

.spinner--secondary {
  border-top-color: var(--accent-secondary);
}

/* --- Dot Spinner (inline) --- */
.dot-spinner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.dot-spinner__dot {
  width: var(--space-1\.5);
  height: var(--space-1\.5);
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  animation: dot-bounce 1.4s ease-in-out infinite both;
}

.dot-spinner__dot:nth-child(2) { animation-delay: 0.16s; }
.dot-spinner__dot:nth-child(3) { animation-delay: 0.32s; }

.dot-spinner--secondary .dot-spinner__dot {
  background: var(--accent-secondary);
}

.dot-spinner--muted .dot-spinner__dot {
  background: var(--text-muted);
}

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Bar Loader (indeterminate) --- */
.bar-loader {
  width: 100%;
  height: var(--space-0\.5);
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.bar-loader__track {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  animation: bar-slide 1.5s ease-in-out infinite;
}

.bar-loader--secondary .bar-loader__track {
  background: var(--accent-secondary);
}

@keyframes bar-slide {
  0% { left: -40%; }
  100% { left: 100%; }
}

/* --- Determinate Progress Bar --- */
.progress-bar {
  width: 100%;
  height: var(--space-1);
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--easing-default);
}

.progress-bar--success .progress-bar__fill {
  background: var(--status-success);
}

/* --- Pulse Spinner (full-page / section placeholder) --- */
.pulse-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.pulse-spinner__ring {
  width: var(--space-12);
  height: var(--space-12);
  border-radius: var(--radius-full);
  border: var(--space-0\.5) solid var(--accent-primary);
  animation: pulse-ring 1.5s ease-out infinite;
}

.pulse-spinner__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* --- Matrix Rain (branded) --- */
.matrix-loader {
  position: relative;
  width: var(--progress-width);
  height: var(--progress-width);
  overflow: hidden;
  background: var(--terminal-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.matrix-loader__rain {
  position: absolute;
  inset: 0;
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  overflow: hidden;
}

.matrix-loader__column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-0\.5);
  animation: matrix-fall linear infinite;
}

.matrix-loader__column:nth-child(1) { animation-duration: 2.1s; }
.matrix-loader__column:nth-child(2) { animation-duration: 1.7s; animation-delay: -0.3s; }
.matrix-loader__column:nth-child(3) { animation-duration: 2.4s; animation-delay: -0.8s; }
.matrix-loader__column:nth-child(4) { animation-duration: 1.9s; animation-delay: -0.5s; }
.matrix-loader__column:nth-child(5) { animation-duration: 2.6s; animation-delay: -1.1s; }
.matrix-loader__column:nth-child(6) { animation-duration: 1.5s; animation-delay: -0.2s; }
.matrix-loader__column:nth-child(7) { animation-duration: 2.2s; animation-delay: -0.7s; }
.matrix-loader__column:nth-child(8) { animation-duration: 1.8s; animation-delay: -1.3s; }

.matrix-loader__char {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1;
  color: var(--accent-primary);
  opacity: 0.3;
  text-align: center;
}

.matrix-loader__char:first-child {
  opacity: 0.9;
  text-shadow: 0 0 var(--space-2) var(--accent-primary);
}

.matrix-loader__char:nth-child(2) {
  opacity: 0.6;
}

@keyframes matrix-fall {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

.matrix-loader__overlay {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent-primary);
  text-shadow: 0 0 var(--space-3) var(--accent-primary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* ======================
   COMPONENT: DROPDOWN / SELECT — Glass Panel
   Frosted glass menu, gradient border glow, left accent bar
   ====================== */
.dropdown {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  width: 100%;
}

.dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  height: var(--input-height-sm);
  padding: var(--space-1) var(--space-3);
  background: color-mix(in srgb, var(--bg-surface) 70%, transparent);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  cursor: pointer;
  transition: all var(--duration-normal) cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown__trigger:hover {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--bg-elevated) 80%, transparent);
}

.dropdown--open .dropdown__trigger {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 25%, transparent),
              var(--glow-accent);
}

.dropdown__trigger--error {
  border-color: var(--status-error);
  box-shadow: 0 0 0 1px var(--status-error-subtle);
}

.dropdown__trigger--disabled {
  background: var(--bg-page);
  color: var(--text-disabled);
  border-color: var(--border-default);
  cursor: not-allowed;
  pointer-events: none;
}

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

.dropdown__chevron {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform var(--duration-normal) cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.dropdown__chevron svg {
  width: var(--space-4);
  height: var(--space-4);
}

.dropdown--open .dropdown__chevron {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.dropdown__menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--space-1);
  background: color-mix(in srgb, var(--bg-elevated) 85%, transparent);
  backdrop-filter: blur(calc(var(--glass-blur) * 2)) saturate(1.4);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 2)) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--border-strong) 60%, transparent);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg),
              0 0 0 1px color-mix(in srgb, var(--accent-primary) 8%, transparent),
              inset 0 1px 0 color-mix(in srgb, white 5%, transparent);
  overflow: hidden;
  padding: var(--space-1) 0;
  z-index: 10;
}

.dropdown--open > .dropdown__menu {
  display: block;
}

.dropdown__group-label {
  padding: var(--space-2) var(--space-4) var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.dropdown__group-label:not(:first-child) {
  margin-top: var(--space-1);
  border-top: 1px solid color-mix(in srgb, var(--border-default) 50%, transparent);
  padding-top: var(--space-3);
}

.dropdown__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-4);
  height: var(--space-4);
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--easing-default);
}

.dropdown__icon svg {
  width: 100%;
  height: 100%;
}

.dropdown__option:hover .dropdown__icon {
  color: var(--text-primary);
}

.dropdown__option--selected .dropdown__icon {
  color: var(--accent-primary);
}

.dropdown__option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  margin: 0 var(--space-1);
  border-left: 3px solid transparent;
  font-size: var(--text-base);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-default);
}

.dropdown__option:hover {
  background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
}

.dropdown__option--selected {
  color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 10%, transparent);
  border-left-color: var(--accent-primary);
}

.dropdown__option--selected::after {
  content: '';
  margin-left: auto;
  width: var(--space-4);
  height: var(--space-4);
  background: var(--accent-primary);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 8l4 4 6-7'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 8l4 4 6-7'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  flex-shrink: 0;
}

/* ======================
   COMPONENT: DATE INPUT
   ====================== */
.date-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: var(--input-height-sm);
  padding: var(--space-1) var(--space-3);
  background: rgba(10, 10, 25, 0.55);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  letter-spacing: var(--tracking-normal);
  outline: none;
  transition: border-color var(--duration-fast) var(--easing-default),
              box-shadow var(--duration-fast) var(--easing-default);
  cursor: pointer;
}

.date-input__icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.date-input__icon svg {
  width: var(--space-4);
  height: var(--space-4);
}

.date-input__value {
  flex: 1;
}

.date-input__placeholder {
  color: var(--text-muted);
}

.date-input:focus,
.date-input--focused {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 var(--space-0\.5) var(--accent-primary-subtle),
              0 0 12px var(--accent-primary-glow);
}

.date-input--focused .date-input__icon {
  color: var(--accent-primary);
}

.date-input--error {
  border-color: var(--status-error);
  box-shadow: 0 0 0 var(--space-0\.5) var(--status-error-subtle);
}

.date-input--error .date-input__icon {
  color: var(--status-error);
}

.date-input--disabled {
  background: var(--bg-page);
  color: var(--text-disabled);
  border-color: var(--border-default);
  cursor: not-allowed;
}

.date-input--disabled .date-input__icon {
  color: var(--text-disabled);
}

/* ======================
   COMPONENT: EMAIL INPUT
   ====================== */
.email-input-wrap {
  position: relative;
}

.email-input-wrap .input {
  padding-right: var(--space-8);
}

.email-input__status {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.email-input__status svg {
  width: var(--space-4);
  height: var(--space-4);
}

.email-input__status--valid {
  color: var(--status-success);
}

.email-input__status--invalid {
  color: var(--status-error);
}

/* ======================
   COMPONENT: TERMINAL CHROME
   ====================== */
.terminal-chrome {
  background: var(--terminal-bg);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6),
              0 0 8px rgba(0, 212, 255, 0.1);
}

.terminal-chrome__titlebar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--rhythm-half) var(--space-4);
  background: rgba(33, 33, 54, 0.32);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border-default);
}

.terminal-chrome__dots {
  display: flex;
  gap: var(--space-1\.5);
}

.terminal-chrome__dot {
  width: var(--space-2);
  height: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--border-strong);
}


.terminal-chrome__title {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
}

.terminal-chrome__body {
  padding: var(--rhythm-1) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--lh-mono);
  color: var(--terminal-text);
  min-height: calc(var(--baseline) * 12);
}

.terminal-chrome__line {
  white-space: pre;
  overflow-x: auto;
}

.terminal-chrome__prompt {
  color: var(--accent-primary);
}

.terminal-chrome__comment {
  color: var(--text-muted);
}

/* ======================
   COMPONENT: BREADCRUMB
   ====================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb__link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--easing-default);
}

.breadcrumb__link:hover {
  color: var(--accent-primary);
}

.breadcrumb__separator {
  color: var(--text-disabled);
}

.breadcrumb__current {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
  font-family: var(--font-mono);
}

/* ======================
   COMPONENT: PREV/NEXT NAV
   ====================== */
.nav-arrows {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-8);
  height: var(--space-8);
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-default);
}

.nav-arrow:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-arrow--disabled {
  color: var(--text-disabled);
  border-color: var(--border-default);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.5;
}

.nav-arrow svg {
  width: var(--space-4);
  height: var(--space-4);
}

/* ======================
   COMPONENT: FILTER PILLS
   ====================== */
.filter-pills {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: rgba(10, 10, 25, 0.55);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-default);
}

.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-pill--active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-primary-subtle);
}

/* ======================
   COMPONENT: UPLOAD ZONE — Uploading state title
   ====================== */
.upload-zone--uploading .upload-zone__title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Upload zone compact variant (modal context) */
.upload-zone--compact {
  padding: var(--rhythm-1) var(--space-6);
}

.upload-zone--compact .upload-zone__title {
  font-size: var(--text-base);
}

/* ======================
   COMPONENT: MODAL — Body stack layout
   ====================== */
.modal__body-stack {
  display: flex;
  flex-direction: column;
  gap: var(--rhythm-1);
}

/* ======================
   COMPONENT: INPUT — Valid state
   ====================== */
.input--valid,
.input--valid:focus {
  border-color: var(--status-success);
  box-shadow: 0 0 0 var(--space-0\.5) var(--status-success-subtle),
              0 0 12px color-mix(in srgb, var(--status-success) 40%, transparent);
}

.input-group__helper--valid {
  color: var(--status-success);
}

/* ======================
   COMPONENT: SPINNER — Inline label
   ====================== */
.spinner__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-left: var(--space-2);
}

/* ======================
   COMPONENT: TERMINAL CHROME — Titlebar spacer
   ====================== */
.terminal-chrome__spacer {
  width: var(--space-12);
}

/* ======================
   COMPONENT: DROPDOWN — Static showcase overrides
   ====================== */
.dropdown--static .dropdown__menu {
  display: block;
  position: relative;
  top: auto;
  margin-top: var(--space-2);
}

/* ======================
   COMPOSITION: SESSION VIEWER
   ======================
   Composition-glue styles for combining terminal-chrome, section-header,
   badge, and button components into the session document viewer.
   These are NOT standalone component styles — they orchestrate existing components.
   ====================== */

/* Titlebar metadata — right-aligned info in terminal titlebar */
.session-viewer__meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  white-space: nowrap;
}

/* Section stack inside terminal body — removes terminal body padding
   and stacks section headers flush edge-to-edge */
.session-viewer__sections {
  display: flex;
  flex-direction: column;
}

/* Section header inside viewer — flush to edges, no border-radius,
   first/last get terminal-chrome radius inheritance */
.session-viewer__sections .section-header {
  border-radius: 0;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid var(--border-default);
}

/* Content block below an expanded section header */
.session-viewer__content {
  padding: var(--rhythm-half) var(--rhythm-1);
  border-bottom: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--lh-mono);
  color: var(--terminal-text);
  background: var(--terminal-bg);
}

/* Line number + content row inside viewer */
.session-viewer__line {
  display: flex;
  gap: var(--space-4);
}

.session-viewer__line-no {
  color: var(--text-disabled);
  user-select: none;
  min-width: var(--space-8);
  text-align: right;
  flex-shrink: 0;
}

.session-viewer__line-text {
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

/* Tool call highlight inside viewer content */
.session-viewer__tool-call {
  color: var(--accent-primary);
}

.session-viewer__tool-name {
  color: var(--accent-primary);
  font-weight: var(--weight-medium);
}

/* Indented continuation — for wrapped/nested content */
.session-viewer__indent {
  padding-left: var(--space-6);
  color: var(--text-secondary);
}

/* ======================
   Scrollbar — TRON utility (.scrollbar)
   ======================
   Apply to any overflow-y:scroll container for custom scrollbar styling.
   Thin cyan-accented thumb with subtle glow, near-invisible track.

   Browser support notes:
   - Firefox: uses scrollbar-width + scrollbar-color (standard properties below).
   - Chrome / Edge: uses ::-webkit-scrollbar pseudo-elements below.
   - Safari: does NOT support ::-webkit-scrollbar. It uses the standard
     scrollbar-width + scrollbar-color properties (Safari 18+). Combine with
     overflow-y:scroll on the container so the scrollbar is always visible
     (Safari hides overlay scrollbars on inactive scroll containers).
   ====================== */

.scrollbar {
  /* overflow-y:scroll keeps the scrollbar permanently rendered.
     Required for Safari — overlay scrollbars only appear while actively scrolling,
     making the custom colour invisible without this. */
  overflow-y: scroll;
  /* Standard properties: Firefox + Safari 18+ */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent-primary) 45%, transparent) transparent;
}

/* Chrome / Edge / Safari — ::-webkit-scrollbar is supported but Safari uses overlay
   scrollbars that auto-hide; the scrollbar-width/scrollbar-color above handles styling
   in Firefox and Safari 18+. These rules apply custom colours for Chromium-based browsers. */
.scrollbar::-webkit-scrollbar {
  width: 6px;
}

.scrollbar::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--accent-primary) 3%, transparent);
}

.scrollbar::-webkit-scrollbar-thumb {
  background: var(--accent-primary-glow);
  border-radius: var(--radius-full);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent-primary) 25%, transparent);
}

.scrollbar::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent-primary) 60%, transparent);
  box-shadow: 0 0 8px var(--accent-primary-glow);
}

.scrollbar::-webkit-scrollbar-thumb:active {
  background: var(--accent-primary-glow-strong);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent-primary) 50%, transparent);
}

/* ================================================================
   RESPONSIVE — COMPONENT OVERRIDES
   ================================================================
   Must appear AFTER all base component styles so media-query rules
   win at equal specificity.
   ================================================================ */
@media (max-width: 767px) {
  /* Cards: prevent flex-item overflow */
  .card {
    min-width: 0;
  }

  /* Section header: allow range text to wrap */
  .section-header {
    flex-wrap: wrap;
  }

  .section-header__range {
    flex-basis: 100%;
    padding-left: var(--space-8);
  }

  /* Session viewer meta: allow wrapping */
  .session-viewer__meta {
    flex-wrap: wrap;
    white-space: normal;
  }
}
