:root {
  --olx-mint: #a2ffb3;
  --olx-mint-header: #a2ffb3;
  --olx-mint-dark: #2d8a45;
  --olx-mint-soft: #c8ffd4;
  --olx-subtitle-green: #1a4d28;
  --olx-status-green: #2d6b3d;
  --page-bg: #121212;
  --card-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --text-dark: #111111;
  --text-muted: #5c5c5c;
  --chat-bg: #ffffff;
  --chat-scroll-bg: #f5f5f5;
  --bubble-user: #f0f4f1;
  --bubble-olly: #ffffff;
  --border-soft: #e0e0e0;
  --input-border: #a8e0a8;
  --send-border: #d0d0d0;
  --send-icon: #888888;
  --radius-card: 22px;
  --radius-bubble: 18px;
  --radius-pill: 999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

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

html {
  background: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--text-dark);
  background: transparent;
  overflow: hidden;
}

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

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #0d0d0d 0%, var(--page-bg) 100%);
  pointer-events: none;
}

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: stretch;
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 16px calc(12px + var(--safe-bottom));
}

.chat-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: 24px 24px 20px 20px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.api-warning {
  flex-shrink: 0;
  margin: 0;
  padding: 10px 14px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #5a2d2d;
  background: #fde8e8;
  border-bottom: 1px solid #f5c4c4;
}

.api-warning code {
  font-size: 0.7rem;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
}

.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 18px;
  background: var(--olx-mint-header);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.brand-avatar-wrap {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.55),
    0 3px 14px rgba(0, 0, 0, 0.18);
}

.brand-avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 36%;
  transform: scale(1.28);
  transform-origin: 50% 40%;
}

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

.title {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-dark);
}

.subtitle {
  display: block;
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--olx-subtitle-green);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--olx-status-green);
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--olx-mint-dark);
  box-shadow: 0 0 0 2px rgba(45, 107, 61, 0.2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.header-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(0, 60, 20, 0.12);
  color: var(--text-dark);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

.header-btn:hover {
  background: rgba(0, 60, 20, 0.2);
}

.header-btn:focus-visible {
  outline: 2px solid var(--text-dark);
  outline-offset: 2px;
}

.header-btn.header-btn-close {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.22);
  color: #000;
}

.header-btn.header-btn-close:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.3);
}

.header-btn.header-btn-close .header-btn-glyph {
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1;
  color: #000;
}

.header-btn-glyph {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
}

.chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--chat-bg);
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--chat-scroll-bg);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.chat-scroll::-webkit-scrollbar {
  width: 6px;
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.welcome-panel {
  flex-shrink: 0;
  padding: 16px 16px 12px;
  background: var(--chat-scroll-bg);
  border-bottom: 1px solid var(--border-soft);
}

.welcome-panel[hidden] {
  display: none !important;
}

.welcome-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
}

.olly-msg-mark-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.olly-msg-mark-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.welcome-bubble {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  background: var(--bubble-olly);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
}

.welcome-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-dark);
}

.quick-replies {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-reply {
  padding: 10px 12px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-dark);
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.quick-reply:hover {
  border-color: var(--olx-mint-dark);
  background: rgba(168, 232, 138, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.quick-reply:focus-visible {
  outline: 2px solid var(--olx-mint-dark);
  outline-offset: 2px;
}

.thread {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--chat-scroll-bg);
}

.row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: 100%;
  animation: row-in 0.35s ease forwards;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.row.olly {
  flex-direction: row;
  align-items: flex-end;
  align-self: flex-start;
  gap: 10px;
}

.olly-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.bubble {
  max-width: min(90%, 300px);
  padding: 12px 14px;
  border-radius: var(--radius-bubble);
  font-size: 0.9375rem;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: normal;
}

.bubble.user {
  background: var(--bubble-user);
  color: var(--text-dark);
  border: 1px solid #e0e8e2;
  border-bottom-right-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.bubble.olly {
  background: var(--bubble-olly);
  color: var(--text-dark);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.bubble.olly.is-pending {
  padding: 14px 18px;
  min-width: 56px;
}

.bubble .bubble-link {
  color: #1a6b3a;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.bubble .bubble-link:hover {
  color: #0d4a28;
}

.bubble.user .bubble-link {
  color: #0d4a6e;
}

.bubble.user .bubble-link:hover {
  color: #063049;
}

.label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 4px;
}

.row.olly .label {
  display: none;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 1em;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--olx-mint-dark);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

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

.composer-wrap {
  flex-shrink: 0;
  padding: 12px 14px 14px;
  background: var(--chat-bg);
  border-top: 1px solid var(--border-soft);
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  border-radius: 12px;
  border: 2px solid var(--input-border);
  background: #fff;
  transition: box-shadow 0.2s ease;
}

.composer:focus-within {
  box-shadow: 0 0 0 3px rgba(168, 224, 168, 0.35);
}

.composer input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-dark);
  font: inherit;
  font-size: 0.9375rem;
  padding: 10px 0;
}

.composer input::placeholder {
  color: #999;
}

.send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 1px solid var(--send-border);
  border-radius: 10px;
  background: #fff;
  color: var(--send-icon);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    border-color 0.2s ease;
}

.send:hover {
  transform: scale(1.03);
  background: #fafafa;
  border-color: #bbb;
}

.send:active {
  transform: scale(0.97);
}

.send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.send-icon {
  margin-left: 2px;
  opacity: 0.9;
}

.empty-hint {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 32px 16px;
  max-width: 280px;
}

body.is-minimized .shell,
body.is-minimized .ambient {
  display: none;
}

body.is-minimized {
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
  color-scheme: dark;
}

.olly-resting {
  position: fixed;
  z-index: 20;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  width: min(320px, calc(100vw - 24px));
}

.olly-resting-open {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.olly-resting-open:focus-visible {
  outline: 2px solid var(--olx-mint-header);
  outline-offset: 4px;
}

.olly-resting-stack {
  position: relative;
  width: 100%;
  padding: 0;
  transition: transform 0.22s ease;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.olly-resting-stage {
  position: relative;
  overflow: hidden;
  line-height: 0;
  border-radius: 4px;
}

.olly-resting-open:hover .olly-resting-stack {
  transform: scale(1.02);
}

.olly-resting-open:active .olly-resting-stack {
  transform: scale(0.99);
}

/* Single design asset: speech bubble + 3D bot on charcoal (see public/olly-resting.png) */
.olly-resting-composite {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
  user-select: none;
  pointer-events: none;
}

.olly-resting-unread {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--olx-mint-dark);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.92),
    0 1px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.row.is-restored {
  animation: none;
}

@media (min-width: 600px) {
  .shell {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 360px) {
  .quick-replies {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row,
  .typing-dots span {
    animation: none;
  }

  .send {
    transition: none;
  }

  .olly-resting-stack {
    transition: none;
  }

  .olly-resting-open:hover .olly-resting-stack,
  .olly-resting-open:active .olly-resting-stack {
    transform: none;
  }
}
