/* ============================================
   ARKSPAN — COMPONENTS
   Tesla-architecture primitives.
   ============================================ */

/* ============================================
   1. FULL-BLEED SECTION SYSTEM
   The core page unit. Every page is a vertical
   stack of these — no card grids in the spine.
   ============================================ */
.tv-section {
  position: relative;
  width: 100%;
  min-height: var(--viewport-section);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  /* Gutters on every panel — content must never touch the viewport edge */
  padding: calc(var(--header-height) + var(--space-16)) clamp(1.25rem, 4vw, 3rem) var(--space-20);
  text-align: center;
  overflow: hidden;
  isolation: isolate;
  background-color: var(--bg-primary);
}

/* Media backdrop */
.tv-section__media {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.tv-section__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.25) 38%,
    rgba(0, 0, 0, 0.72) 100%
  );
}
.tv-section--scrim-soft .tv-section__scrim {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.15) 45%, rgba(0, 0, 0, 0.6) 100%);
}
/* Text-heavy panels: hold the ink legible right through the middle band */
.tv-section--scrim-deep .tv-section__scrim {
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.6) 45%,
    rgba(0, 0, 0, 0.8) 100%
  );
}

/* Section body */
.tv-section__body {
  position: relative;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Column-flex children shrink to fit-content unless told to fill the panel. */
.tv-section__body > .tv-specs,
.tv-section__body > .tv-grid,
.tv-section__body > .tv-steps,
.tv-section__body > .tv-split,
.tv-section__body > .product-grid,
.tv-section__body > .research-grid,
.tv-section__body > .job-grid,
.tv-section__body > .product-proof__grid,
.tv-section__body > .product-catalogue__header,
.tv-section__body > .product-page__content,
.tv-section__body > .product-page__hero-grid,
.tv-section__body > .contact-grid,
.tv-section__body > .policy-content,
.tv-section__body > .link-row {
  width: 100%;
}
/* Panels are centred by default — content blocks opt back out */
.tv-section__body > .tv-grid,
.tv-section__body > .tv-split,
.tv-section__body > .tv-steps,
.tv-section__body > .product-grid,
.tv-section__body > .research-grid,
.tv-section__body > .job-grid,
.tv-section__body > .tv-faq,
.tv-section__body > .contact-grid,
.tv-section__body > .product-catalogue__header,
.tv-section__body > .product-page__content,
.tv-section__body > .policy-content {
  text-align: left;
}
.tv-section--start .tv-section__body {
  align-items: flex-start;
  text-align: left;
}

.tv-section__eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  margin-bottom: var(--space-4);
  color: rgba(255, 255, 255, 0.78);
}
.tv-section__title {
  font-size: var(--display-lg);
  font-weight: 300;
  line-height: var(--leading-headline);
  letter-spacing: var(--tracking-display);
  color: var(--text-on-media);
  max-width: 22ch;
  margin: 0 auto;
  text-wrap: balance;
}
.tv-section__title--wide {
  max-width: 34ch;
}
.tv-section__lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: rgba(255, 255, 255, 0.82);
  max-width: 60ch;
  margin: var(--space-5) auto 0;
}
.tv-section__links {
  margin-top: var(--space-8);
}
.tv-section__links a {
  color: #fff;
  font-size: var(--text-base);
  font-weight: 500;
}
.tv-section__links a::after {
  background: #fff;
}

/* Body prose inside a media panel — sits under the lead without competing */
.tv-section__prose {
  max-width: 62ch;
  margin: var(--space-5) auto 0;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: rgba(255, 255, 255, 0.72);
}
.tv-section__prose + .tv-section__prose {
  margin-top: var(--space-4);
}

/* Restrained status pill — "In development" and the like */
.tv-section__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-7);
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}
.tv-section__status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* Variants — non-hero bands stay short and flat like Tesla's content pages */
.tv-section--band {
  min-height: auto;
  padding-top: var(--section-pad);
  padding-bottom: var(--section-pad);
  color: var(--text-primary);
}
.tv-section--band .tv-section__body {
  max-width: var(--max-width);
}
.tv-section--gray {
  background: var(--bg-band);
}
.tv-section--dark {
  background: #000;
  color: #fff;
}
.tv-section--dark .tv-section__title {
  color: #fff;
}
.tv-section--dark .tv-section__lead {
  color: rgba(255, 255, 255, 0.74);
}
.tv-section--dark .tv-section__eyebrow {
  color: rgba(255, 255, 255, 0.6);
}
.tv-section--dark .tv-section__links a {
  color: #fff;
}
.tv-section--dark .tv-head__title {
  color: #fff;
}
.tv-section--dark .tv-head__lead {
  color: rgba(255, 255, 255, 0.7);
}
.tv-section--dark .eyebrow {
  color: rgba(255, 255, 255, 0.6);
}
.tv-section--dark .tv-step {
  border-top-color: #fff;
}
/* Any ink inside a dark panel must invert — headings included */
.tv-section--dark h1,
.tv-section--dark h2,
.tv-section--dark h3,
.tv-section--dark h4,
.tv-section--dark h5,
.tv-section--dark h6,
.tv-section--dark strong {
  color: #fff;
}
.tv-section--dark p,
.tv-section--dark li,
.tv-section--dark .tv-tile__desc,
.tv-section--dark .tv-step__desc,
.tv-section--dark .product-card__desc {
  color: rgba(255, 255, 255, 0.74);
}
.tv-section--dark .tv-tile__title,
.tv-section--dark .product-card__title,
.tv-section--dark .research-card__title,
.tv-section--dark .job-card__title {
  color: #fff;
}
.tv-section--dark .tv-step__desc {
  color: rgba(255, 255, 255, 0.68);
}
.tv-section--top {
  justify-content: flex-start;
  padding-top: calc(var(--header-height) + var(--space-16));
}
.tv-section--short {
  min-height: auto;
  padding-top: var(--band-pad);
  padding-bottom: var(--band-pad);
}

/* Inverted (on light canvas) type colour */
.tv-section--band .tv-section__eyebrow {
  color: var(--accent);
}
.tv-section--band .tv-section__title {
  color: var(--text-primary);
}
.tv-section--band .tv-section__lead {
  color: var(--text-secondary);
}
.tv-section--band .tv-section__links a {
  color: var(--text-primary);
}
.tv-section--band .tv-section__links a::after {
  background: var(--text-primary);
}

/* Scroll cue — the down-chevron at the base of every Tesla panel */
.tv-scroll {
  position: absolute;
  left: 50%;
  bottom: var(--space-8);
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 10px;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
}
.tv-scroll svg {
  animation: scrollCue 2.1s ease-in-out infinite;
}
.tv-scroll:hover {
  color: #fff;
}

/* Section head used by bands */
.tv-head {
  text-align: center;
  max-width: 820px;
  margin: 0 auto var(--section-pad);
}
.tv-head--start {
  text-align: left;
  margin-left: 0;
}
.tv-head__title {
  font-size: var(--display-md);
  font-weight: 300;
  letter-spacing: var(--tracking-display);
  color: var(--text-primary);
  text-wrap: balance;
}
.tv-head__lead {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-top: var(--space-4);
  max-width: 62ch;
}
.tv-head--start .tv-head__lead {
  margin-left: 0;
}

/* Closing wordmark line under the engineering philosophy */
.tv-signoff {
  margin: var(--space-12) auto 0;
  padding-top: var(--space-8);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  max-width: 520px;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

/* ============================================
   2. SPLIT BAND — sticky heading + scrolling detail
   ============================================ */
.tv-split {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}
.tv-split__aside {
  position: sticky;
  top: calc(var(--header-height) + var(--space-8));
}
.tv-split__aside h2 {
  font-size: var(--display-md);
  font-weight: 300;
  letter-spacing: var(--tracking-display);
  margin-bottom: var(--space-4);
}
.tv-split__aside p {
  font-size: var(--text-lg);
  color: var(--text-secondary);
}
.tv-split__content > * + * {
  margin-top: var(--space-10);
}

/* ============================================
   3. SPEC ROW — Tesla's stats-as-spec-sheet
   ============================================ */
.tv-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  border-top: 1px solid var(--border);
}
.tv-specs__cell {
  padding: var(--space-8) var(--space-4);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
}
.tv-specs__cell:last-child {
  border-right: none;
}
.tv-specs__value {
  font-size: var(--display-sm);
  font-weight: 300;
  letter-spacing: var(--tracking-display);
  line-height: 1;
  color: var(--text-primary);
  display: block;
}
.tv-specs__label {
  display: block;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ============================================
   4. TILE GRID — flat, 1px border, no shadow
   ============================================ */
.tv-grid {
  display: grid;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
}
.tv-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.tv-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.tv-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tv-grid--auto {
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}

.tv-tile {
  background: var(--bg-primary);
  padding: clamp(1.75rem, 3vw, 2.75rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: background var(--transition-base);
}
.tv-tile:hover {
  background: var(--bg-tertiary);
}
.tv-tile__icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: var(--space-2);
}
.tv-tile__icon svg {
  width: 100%;
  height: 100%;
}
.tv-tile__title {
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.tv-tile__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.tv-tile__list {
  list-style: none;
  margin-top: var(--space-2);
}
.tv-tile__list li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: 6px 0;
  border-top: 1px solid var(--border-light);
}

/* ============================================
   5. NUMBERED STEPS — no bubbles, plain index
   ============================================ */
.tv-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: var(--space-10);
  counter-reset: tvstep;
}
.tv-step {
  counter-increment: tvstep;
  border-top: 2px solid var(--text-primary);
  padding-top: var(--space-4);
}
.tv-step::before {
  content: '0' counter(tvstep);
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  color: var(--accent);
  margin-bottom: var(--space-3);
}
.tv-step__title {
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: var(--space-2);
}
.tv-step__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ============================================
   6. BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-8);
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: var(--tracking-tight);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base),
    border-color var(--transition-base);
}
.btn-primary {
  background: #000;
  color: #fff;
  border-color: #000;
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-dark);
}
.btn-secondary:hover {
  background: #000;
  border-color: #000;
  color: #fff;
}
.btn-light {
  background: #fff;
  color: #000;
  border-color: #fff;
}
.btn-light:hover {
  background: transparent;
  color: #fff;
}
.btn-outline {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}
.btn-outline:hover {
  background: #fff;
  border-color: #fff;
  color: #000;
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 0 var(--space-3);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.btn-sm {
  min-height: 34px;
  padding: 0 var(--space-5);
  font-size: var(--text-xs);
}
.btn-lg {
  min-height: 52px;
  padding: 0 var(--space-10);
  font-size: var(--text-base);
}
.btn-xl {
  min-height: 58px;
  padding: 0 var(--space-12);
  font-size: var(--text-lg);
}
.btn-block {
  width: 100%;
}

[data-theme='dark'] .btn-primary {
  background: #fff;
  color: #000;
  border-color: #fff;
}
[data-theme='dark'] .btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================
   7. BADGES + TAGS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.badge--muted {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.badge--success {
  background: #e6f4ea;
  color: #0d652d;
}
.badge--warning {
  background: #fdf3e0;
  color: #8a5a00;
}
.badge--danger {
  background: var(--accent-light);
  color: var(--accent-hover);
}
.badge--info {
  background: #e8f0fb;
  color: #1a4f8a;
}
[data-theme='dark'] .badge--success {
  background: rgba(22, 163, 74, 0.18);
  color: #6ee7a1;
}
[data-theme='dark'] .badge--warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}
[data-theme='dark'] .badge--danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}
[data-theme='dark'] .badge--info {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

/* ============================================
   8. CARD (legacy flat surface, retained for admin + legal)
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 3vw, 2.5rem);
}
.card--accent {
  border-color: var(--accent);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

/* ============================================
   9. FORMS — Tesla-style underline fields
   ============================================ */
.form-group {
  margin-bottom: var(--space-5);
}
.form-group label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-3) 0;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-dark);
  border-radius: 0;
  transition: border-color var(--transition-fast);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
.form-textarea {
  resize: vertical;
  min-height: 130px;
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}
.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--accent);
  margin-top: var(--space-1);
}

/* ============================================
   10. MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 4vw, 3rem);
  max-width: 520px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform var(--transition-base);
}
.modal-overlay.active .modal {
  transform: translateY(0);
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-2xl);
  line-height: 1;
}
.modal__close:hover {
  color: var(--text-primary);
}

/* ============================================
   11. FAQ — flat list, hairline separators
   ============================================ */
.tv-faq {
  border-top: 1px solid var(--border);
}
.tv-faq__item {
  border-bottom: 1px solid var(--border);
}
.tv-faq__q {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-6) 0;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.tv-faq__q::after {
  content: '+';
  flex-shrink: 0;
  font-size: var(--text-xl);
  font-weight: 300;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}
.tv-faq__item.open .tv-faq__q::after {
  transform: rotate(45deg);
}
.tv-faq__a {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
}
.tv-faq__item.open .tv-faq__a {
  max-height: 600px;
}
.tv-faq__a-inner {
  padding: 0 0 var(--space-6);
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 70ch;
}

/* ============================================
   12. CHAT WIDGET
   ============================================ */
.chat-widget {
  position: fixed;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  left: var(--space-6);
  z-index: 90;
  font-family: var(--font-sans);
}
.chat-toggle {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-base);
}
.chat-toggle:hover {
  background: var(--accent);
}
.chat-toggle svg {
  width: 22px;
  height: 22px;
}
.chat-panel {
  position: absolute;
  bottom: 64px;
  left: 0;
  width: 380px;
  max-height: 700px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all var(--transition-base);
  overflow: hidden;
}
.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.chat-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
/* Only the close button is pushed to the far edge — the title stays with the icon */
.chat-header button {
  margin-left: auto;
}
/* AI mark — twinkling sparkles */
@keyframes aiOrbit {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(7deg); }
}
@keyframes aiTwinkle {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.66); opacity: 0.5; }
}
.chat-ai-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--accent);
  animation: aiOrbit 5.5s ease-in-out infinite;
}
.chat-ai-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chat-ai-icon__frame {
  opacity: 0.55;
  animation: aiTwinkle 3.2s ease-in-out infinite;
}
.chat-ai-icon__spark {
  transform-origin: center;
  transform-box: fill-box;
  animation: aiTwinkle 2.3s ease-in-out infinite;
}
.chat-ai-icon__spark--sm {
  animation-duration: 1.6s;
  animation-delay: 0.45s;
}
.chat-header:hover .chat-ai-icon {
  animation-duration: 2.4s;
}

.chat-header h5 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin: 0;
}
.chat-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-xl);
  line-height: 1;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 360px;
  min-height: 200px;
}
.chat-message {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  animation: fadeInUp 0.3s ease;
  word-wrap: break-word;
}
.chat-message--bot {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  align-self: flex-start;
}
.chat-message--user {
  background: #000;
  color: #fff;
  align-self: flex-end;
}
[data-theme='dark'] .chat-message--user {
  background: #fff;
  color: #000;
}
.chat-typing {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  align-self: flex-start;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 1.4s ease infinite;
}
.chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}
.chat-input {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-light);
}
.chat-input input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  background: var(--bg-input);
  color: var(--text-primary);
}
.chat-input input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-input button {
  padding: 0 var(--space-4);
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
}
.chat-input button:hover {
  background: var(--accent);
}
[data-theme='dark'] .chat-input button {
  background: #fff;
  color: #000;
}
.chat-rating-widget {
  padding: var(--space-3);
  text-align: center;
}
.chat-rating-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.chat-rating-stars {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
}
.chat-star-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.chat-star {
  color: var(--text-muted);
}

/* Floating widgets retreat when the footer is showing */
/* Specificity must beat layout.css's .back-to-top.visible */
body.footer-visible .chat-widget,
body.footer-visible .back-to-top,
body.footer-visible .back-to-top.visible {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ============================================
   14. MOBILE — Tesla layout: copy on top, image below,
   side-by-side buttons, sticky action bar.
   ============================================ */
.tv-hero__cta {
  display: none;
}

/* Sticky bottom action bar (mobile only) */
.cta-bar {
  display: none;
}

@media (max-width: 1080px) {
  .tv-section {
    min-height: 100dvh;
    justify-content: flex-start;
    padding-top: calc(var(--header-height) + var(--space-8));
    padding-bottom: var(--space-32);
  }
  .tv-section__title {
    font-size: clamp(1.75rem, 7.4vw, 2.75rem);
  }
  .tv-section__lead {
    font-size: var(--text-base);
    margin-top: var(--space-3);
  }

  /* Slide the link row aside and show real buttons instead.
     :not() keeps exception rows that carry content rather than navigation
     — e.g. the NPSOS platform reference — visible on mobile. */
  .tv-section__links:not(.tv-section__links--keep) {
    display: none;
  }
  .tv-hero__cta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-3);
    width: 100%;
    max-width: 460px;
    margin-top: var(--space-6);
  }
  .tv-hero__cta .btn {
    width: 100%;
    min-height: 48px;
    font-size: var(--text-base);
  }

  .tv-scroll,
  .tv-hero__dots {
    bottom: calc(var(--space-28) + env(safe-area-inset-bottom, 0px));
  }
  .tv-hero__dots {
    display: flex;
  }

  /* Sticky action bar, inset like Tesla's "Schedule a Drive" */
  .cta-bar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    background: var(--bg-primary);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -2px 18px rgba(0, 0, 0, 0.08);
    transform: translateY(0);
    transition: transform var(--transition-base);
  }
  .cta-bar.is-hidden {
    transform: translateY(120%);
  }
  .cta-bar__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    min-height: 48px;
    padding: 0 var(--space-6);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
  }
  .cta-bar__btn:active {
    background: var(--bg-tertiary);
  }
  /* chat bubble sits above the bar */
  .chat-widget {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  .chat-panel {
    bottom: 136px;
  }
}

@media (max-width: 480px) {
  .tv-section {
    padding-top: calc(var(--header-height) + var(--space-6));
    padding-bottom: var(--space-28);
  }
  .tv-hero__cta {
    grid-template-columns: 1fr;
  }
  .tv-section__lead {
    font-size: var(--text-sm);
  }
}
/* ============================================
   13. RESPONSIVE — grids, specs, chat
   ============================================ */
@media (max-width: 1024px) {
  .tv-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tv-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tv-split {
    grid-template-columns: 1fr;
  }
  .tv-split__aside {
    position: static;
  }
}

@media (max-width: 768px) {
  .tv-grid--2,
  .tv-grid--3,
  .tv-grid--4 {
    grid-template-columns: 1fr;
  }
  .tv-specs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tv-specs__cell:nth-child(2n) {
    border-right: none;
  }
  .chat-panel {
    width: calc(100vw - var(--space-8));
  }
}

@media (max-width: 480px) {
  .tv-specs {
    grid-template-columns: 1fr;
  }
  .tv-specs__cell {
    border-right: none;
  }
  .btn-lg,
  .btn-xl {
    width: 100%;
  }
  .chat-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 80vh;
  }
}