:root {
  --navy-950: #0a1f33;
  --navy-900: #102a43;
  --navy-800: #163a5f;
  --navy-700: #1f4f78;
  --blue-100: #e9f1f8;
  --blue-50: #f4f8fb;
  --green-600: #168552;
  --green-100: #dff3e9;
  --ink-900: #17202a;
  --ink-700: #3f4b59;
  --ink-500: #687585;
  --line: #d9e1e8;
  --surface: #ffffff;
  --canvas: #eef3f7;
  --customer: #e1f2e9;
  --danger-bg: #fff1f0;
  --danger-text: #9a2c25;
  --app-height: 100dvh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink-900);
  background: var(--canvas);
  color-scheme: light;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: var(--app-height);
  background: var(--canvas);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 79, 120, 0.28);
  outline-offset: 2px;
}

.support-app {
  display: grid;
  width: 100%;
  height: 100vh;
  height: var(--app-height);
  min-height: 0;
  padding: 0;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: calc(13px + env(safe-area-inset-top)) 16px 13px;
  color: #ffffff;
  background: var(--navy-900);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  color: #ffffff;
  background: var(--navy-800);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand-copy {
  min-width: 0;
}

.brand-name,
.service-status,
.welcome-card p,
.security-note,
.scope-notice,
.message-bubble p {
  margin: 0;
}

.brand-name {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header h1 {
  margin: 1px 0 3px;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -0.018em;
}

.service-status {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #56d799;
  box-shadow: 0 0 0 3px rgba(86, 215, 153, 0.13);
}

.scope-notice {
  display: grid;
  gap: 2px;
  padding: 10px 16px;
  color: var(--navy-800);
  background: var(--blue-100);
  border-bottom: 1px solid #d5e2ed;
  font-size: 11.5px;
  line-height: 1.35;
}

.scope-notice strong {
  font-size: 12px;
}

.messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 20px;
  background: var(--blue-50);
  scrollbar-color: #bcc8d3 transparent;
  scrollbar-width: thin;
}

.welcome-card {
  width: min(100%, 470px);
  margin: 0 auto 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(16, 42, 67, 0.06);
}

.welcome-card > p:first-child {
  color: var(--navy-900);
  font-size: 16px;
  font-weight: 750;
}

.welcome-detail {
  margin-top: 5px !important;
  color: var(--ink-700);
  font-size: 12.5px;
  line-height: 1.48;
}

.quick-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.quick-action {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 60px;
  padding: 9px 11px;
  border: 1px solid #cbd8e3;
  border-radius: 12px;
  color: var(--navy-900);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.quick-action:hover {
  border-color: var(--navy-700);
  background: #f8fbfd;
  transform: translateY(-1px);
}

.quick-action:active {
  transform: translateY(0);
}

.quick-action:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.quick-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--navy-900);
  background: var(--blue-100);
  font-size: 12px;
  font-weight: 800;
}

.quick-action strong,
.quick-action small {
  display: block;
}

.quick-action strong {
  font-size: 13px;
  line-height: 1.25;
}

.quick-action small {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 10.5px;
  line-height: 1.3;
}

.remote-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 610px);
  margin: 0 auto;
}

.message-bubble {
  align-self: flex-start;
  max-width: min(86%, 490px);
  padding: 10px 12px 7px;
  border: 1px solid #e1e7ec;
  border-radius: 14px 14px 14px 4px;
  background: var(--surface);
  box-shadow: 0 2px 7px rgba(16, 42, 67, 0.05);
}

.message-bubble.is-customer {
  align-self: flex-end;
  border-color: #cce3d7;
  border-radius: 14px 14px 4px 14px;
  background: var(--customer);
}

.message-bubble p {
  overflow-wrap: anywhere;
  color: var(--ink-900);
  font-size: 13.5px;
  line-height: 1.47;
  white-space: pre-wrap;
}

.message-link {
  color: var(--navy-700);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.message-link:focus-visible {
  border-radius: 3px;
  outline: 3px solid rgba(31, 79, 120, 0.28);
  outline-offset: 2px;
}

.message-bubble time {
  display: block;
  margin-top: 4px;
  color: var(--ink-500);
  font-size: 9.5px;
  line-height: 1;
  text-align: right;
}

.typing-indicator {
  width: fit-content;
  margin: 8px max(0px, calc((100% - 610px) / 2));
  padding: 11px 13px;
  border: 1px solid #e1e7ec;
  border-radius: 14px 14px 14px 4px;
  background: var(--surface);
}

.typing-indicator span:not(.sr-only) {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: #7b8895;
  animation: typing 1.15s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 140ms;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.42;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.composer-area {
  position: relative;
  z-index: 2;
  min-width: 0;
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -7px 18px rgba(16, 42, 67, 0.04);
}

.connection-message {
  max-width: 610px;
  margin: 0 auto 8px;
  padding: 8px 10px;
  border: 1px solid #f0cfcb;
  border-radius: 9px;
  color: var(--danger-text);
  background: var(--danger-bg);
  font-size: 11px;
  line-height: 1.35;
}

.topic-helper {
  width: min(100%, 610px);
  margin: 0 auto 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--navy-700);
  border-radius: 4px 9px 9px 4px;
  color: var(--navy-900);
  background: var(--blue-100);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.35;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  width: min(100%, 610px);
  margin: 0 auto;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 116px;
  resize: none;
  overflow-y: auto;
  padding: 11px 12px;
  border: 1px solid #bfcbd6;
  border-radius: 12px;
  color: var(--ink-900);
  background: #ffffff;
  font-size: 16px;
  line-height: 1.32;
}

.composer textarea::placeholder {
  color: #788492;
}

.composer textarea:focus {
  border-color: var(--navy-700);
}

.send-button {
  min-width: 72px;
  height: 44px;
  padding: 0 15px;
  border-radius: 12px;
  color: #ffffff;
  background: var(--navy-900);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.send-button:hover {
  background: var(--navy-800);
}

.send-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.security-note {
  width: min(100%, 610px);
  margin: 6px auto 0;
  color: var(--ink-500);
  font-size: 9.5px;
  line-height: 1.35;
  text-align: center;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.noscript-message {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--navy-900);
  background: #ffffff;
  font: 600 16px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
}

@media (min-width: 720px) {
  .support-app {
    place-items: center;
    padding: 22px;
  }

  .chat-shell {
    width: min(100%, 780px);
    height: min(900px, calc(var(--app-height) - 44px));
    border: 1px solid #d3dce4;
    border-radius: 20px;
    box-shadow: 0 20px 56px rgba(16, 42, 67, 0.13);
  }

  .chat-header {
    padding: 17px 20px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .chat-header h1 {
    font-size: 20px;
  }

  .scope-notice {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
  }

  .messages {
    padding: 22px 22px 26px;
  }

  .welcome-card {
    padding: 18px;
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }

  .composer-area {
    padding: 12px 20px 10px;
  }
}

@media (max-height: 610px) {
  .scope-notice {
    display: none;
  }

  .welcome-card {
    padding: 12px;
  }

  .welcome-detail {
    display: none;
  }

  .quick-actions {
    margin-top: 9px;
  }

  .quick-action {
    min-height: 50px;
  }
}

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