:root {
  --navy-deep: #07152a;
  --navy: #0d1f3c;
  --navy-mid: #152e55;
  --blue: #1a4faa;
  --blue-bright: #2563eb;
  --blue-soft: #3b82f6;
  --blue-glow: rgba(37, 99, 235, 0.28);

  --surface-0: #ffffff;
  --surface-1: #f8fafd;
  --surface-2: #f0f4fb;
  --surface-3: #e4ecf8;

  --text-primary: #0d1f3c;
  --text-secondary: #4a5e7a;
  --text-muted: #8a9ab5;
  --text-inverse: #ffffff;
  --text-inverse-80: rgba(255, 255, 255, 0.8);
  --text-inverse-55: rgba(255, 255, 255, 0.55);

  --border: rgba(13, 31, 60, 0.09);
  --border-strong: rgba(13, 31, 60, 0.16);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.5);

  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --shadow-panel:
    0 2px 4px rgba(7, 21, 42, 0.04),
    0 8px 24px rgba(7, 21, 42, 0.08),
    0 32px 72px rgba(7, 21, 42, 0.16);
  --shadow-launcher:
    0 4px 12px rgba(13, 31, 60, 0.2),
    0 16px 40px rgba(13, 31, 60, 0.22);
  --shadow-btn:
    0 1px 3px rgba(37, 99, 235, 0.3),
    0 4px 16px rgba(37, 99, 235, 0.22);
}

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

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: transparent;
}

.ts-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.ts-panel {
  width: 350px;
  height: 550px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--surface-0);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
}

.ts-panel.open {
  display: flex;
  animation: panelIn 0.38s var(--ease-expo) forwards;
}

@keyframes panelIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ts-panel-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 16px;
  overflow: hidden;
  flex-shrink: 0;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(255, 255, 255, 0.14) 0%, transparent 50%),
    linear-gradient(140deg, var(--navy-deep) 0%, var(--navy-mid) 55%, #1a3a7a 100%);
}

.ts-panel-header-noise {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 120px 120px;
  pointer-events: none;
  opacity: 0.5;
}

.ts-panel-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.ts-header-left {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  position: relative;
}

.ts-avatar-stack {
  position: relative;
  flex-shrink: 0;
}

.ts-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid rgba(255, 255, 255, 0.7);
  display: block;
}

.ts-status-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 0 var(--green-glow);
  animation: statusPulse 2.8s ease infinite;
}

@keyframes statusPulse {
  0% {
    box-shadow: 0 0 0 0 var(--green-glow);
  }
  60% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.ts-header-copy {
  min-width: 0;
}

.ts-header-eyebrow {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-inverse-55);
  margin-bottom: 2px;
}

.ts-header-name {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--text-inverse);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.ts-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  flex-shrink: 0;
}

.ts-copilot-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-inverse-80);
}

.ts-btn-icon {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-inverse-80);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.ts-btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-inverse);
}

.ts-btn-icon:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.ts-intro {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-0) 100%);
  flex-shrink: 0;
}

.ts-intro.hidden {
  display: none;
}

.ts-intro-spark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px 10px 4px 8px;
  background: rgba(37, 99, 235, 0.07);
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue-bright);
}

.ts-intro-heading {
  margin: 0 0 8px;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.ts-intro-body {
  margin: 0 0 16px;
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 34ch;
}

.ts-starters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ts-starter {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: var(--surface-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s var(--ease-expo),
    box-shadow 0.18s ease;
  text-align: left;
}

.ts-starter:hover {
  background: var(--surface-2);
  border-color: rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.1);
}

.ts-starter:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
}

.ts-starter-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ts-starter-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.ts-body {
  flex: 1;
  min-height: 0;
  background: var(--surface-1);
  position: relative;
}

.ts-body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, var(--surface-1), transparent);
  z-index: 1;
  pointer-events: none;
}

#webchat {
  width: 100%;
  height: 100%;
}

#webchat > * {
  width: 100% !important;
  height: 100% !important;
}

.ts-panel-footer {
  padding: 9px 16px 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-0);
  border-top: 1px solid var(--border);
}

.ts-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  padding: 9px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.22s var(--ease-spring), box-shadow 0.22s ease;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, 0.12) 0%, transparent 55%),
    linear-gradient(140deg, var(--navy-deep) 0%, var(--blue) 60%, var(--blue-bright) 100%);
  box-shadow: var(--shadow-launcher);
  color: var(--text-inverse);
}

.ts-launcher:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(13, 31, 60, 0.26),
    0 20px 50px rgba(13, 31, 60, 0.26);
}

.ts-launcher:active {
  transform: translateY(0);
}

.ts-launcher:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.6);
  outline-offset: 3px;
}

.ts-launcher::before {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  border-radius: 1px;
}

.ts-launcher-ping {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  animation: launcherPing 2.5s ease infinite;
}

@keyframes launcherPing {
  0% {
    box-shadow: 0 0 0 0 var(--green-glow);
  }
  65% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.ts-launcher-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.65);
  display: block;
  flex-shrink: 0;
}

.ts-launcher-copy {
  display: none;
  flex-direction: column;
  gap: 2px;
}

.ts-launcher-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}

.ts-launcher-sub {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.01em;
  line-height: 1;
}

.ts-launcher-chevron {
  display: none;
  margin-left: 2px;
  opacity: 0.6;
  transition: transform 0.22s var(--ease-expo), opacity 0.18s ease;
}

.ts-launcher:hover .ts-launcher-chevron {
  opacity: 0.9;
  transform: translateY(1px);
}

@media (max-width: 640px) {
  .ts-widget {
    right: 14px;
    bottom: 14px;
  }

  .ts-panel {
    width: min(84vw, 350px);
    height: min(75vh, 550px);
    border-radius: var(--r-lg);
  }

  .ts-launcher-copy,
  .ts-launcher-chevron {
    display: none;
  }

  .ts-launcher {
    padding: 9px;
    border-radius: 50%;
    width: 62px;
    height: 62px;
    justify-content: center;
  }

  .ts-launcher::before {
    display: none;
  }

  .ts-launcher-avatar {
    width: 44px;
    height: 44px;
  }

  .ts-launcher-ping {
    top: 5px;
    right: 5px;
  }

  .ts-starters {
    grid-template-columns: 1fr;
  }

  .ts-intro {
    padding: 18px 16px 14px;
  }

  .ts-intro-heading {
    font-size: 1.125rem;
  }

  .ts-intro-body {
    max-width: none;
    font-size: 0.8125rem;
  }

  .ts-panel-header {
    padding: 14px 14px 12px;
  }

  .ts-avatar {
    width: 40px;
    height: 40px;
  }

  .ts-header-name {
    font-size: 1.125rem;
  }

  .ts-copilot-badge {
    display: none;
  }

  .ts-btn-icon {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 480px) {
  .ts-panel {
    width: min(90vw, 320px);
    height: min(80vh, 480px);
    border-radius: var(--r-lg);
  }

  .ts-widget {
    right: 14px;
    bottom: 14px;
  }

  .ts-launcher {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    padding: 6px;
    border-radius: 50%;
  }

  .ts-launcher-avatar {
    width: 44px;
    height: 44px;
  }

  .ts-launcher-ping {
    top: 3px;
    right: 3px;
  }

  .ts-intro {
    padding: 16px;
  }

  .ts-intro-heading {
    font-size: 1rem;
  }

  .ts-intro-body {
    font-size: 0.8125rem;
  }

  .ts-starter {
    padding: 10px;
    gap: 8px;
  }

  .ts-starter-icon {
    width: 26px;
    height: 26px;
  }

  .ts-starter-label {
    font-size: 0.8125rem;
  }

  .ts-panel-header {
    padding: 12px;
  }

  .ts-header-left {
    gap: 10px;
  }

  .ts-avatar {
    width: 36px;
    height: 36px;
  }

  .ts-header-name {
    font-size: 1rem;
  }

  .ts-header-eyebrow {
    font-size: 0.625rem;
  }

  .ts-btn-icon {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 380px) {
  .ts-intro-heading {
    font-size: 0.9375rem;
  }

  .ts-intro-body {
    font-size: 0.75rem;
  }

  .ts-starter-label {
    font-size: 0.75rem;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .ts-panel {
    width: 330px;
    height: 550px;
  }
}

@media (min-width: 1025px) {
  .ts-panel {
    width: 370px;
    height: 600px;
  }
}

@media (max-height: 700px) {
  .ts-panel {
    height: calc(100vh - 60px);
    max-height: 500px;
  }
}

@media (max-height: 500px) {
  .ts-panel {
    height: calc(100vh - 40px);
    max-height: 400px;
  }

  .ts-panel-header {
    padding: 10px 12px;
  }

  .ts-intro {
    padding: 12px;
  }

  .ts-intro-spark {
    display: none;
  }

  .ts-intro-heading {
    font-size: 0.9375rem;
    margin-bottom: 4px;
  }

  .ts-intro-body {
    display: none;
  }

  .ts-starters {
    gap: 4px;
  }

  .ts-starter {
    padding: 6px 8px;
    gap: 6px;
  }

  .ts-starter-icon {
    width: 22px;
    height: 22px;
  }

  .ts-starter-label {
    font-size: 0.75rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .ts-panel {
    height: calc(100vh - 20px);
    max-height: 400px;
  }

  .ts-intro {
    padding: 10px 12px;
  }

  .ts-intro-spark {
    display: none;
  }

  .ts-intro-heading {
    font-size: 0.875rem;
  }

  .ts-intro-body {
    display: none;
  }

  .ts-starters {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .ts-starter {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}