:root {
  --lapig-yellow: #f2c50f;
  --lapig-dark-green: #194f25;
  --lapig-light-green: #8dbb66;
  --lapig-green: #127940;
  --lapig-red: #ba4222;
  --lapig-background: #f3f5fb;
  --ink: #17221a;
  --muted: #536158;
  --line: #d9e1db;
  --surface: #ffffff;
  --panel-width: 430px;
  --panel-radius: 8px;
  --shadow: 0 18px 50px rgba(23, 34, 26, 0.18);
  color-scheme: light;
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  background: var(--lapig-background);
  color: var(--ink);
}

button,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--lapig-yellow);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--lapig-dark-green);
  color: #ffffff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.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;
}

.host-surface {
  min-height: 100vh;
  padding-right: calc(var(--panel-width) + 48px);
}

.host-header {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 92px;
  padding: 12px clamp(24px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.host-header img {
  width: 128px;
  height: 64px;
  object-fit: contain;
}

.host-header span {
  color: var(--lapig-dark-green);
  font-size: 0.95rem;
  font-weight: 700;
}

.host-stage {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(220px, 0.8fr);
  align-items: center;
  gap: clamp(20px, 5vw, 72px);
  min-height: calc(100vh - 92px);
  padding: clamp(32px, 7vw, 96px);
  overflow: hidden;
}

.host-copy {
  max-width: 620px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--lapig-green);
  font-size: 0.875rem;
  font-weight: 800;
  text-transform: uppercase;
}

.host-copy h1 {
  margin: 0;
  color: var(--lapig-dark-green);
  font-size: 4.5rem;
  line-height: 1;
  letter-spacing: 0;
}

.host-copy > p:last-child {
  max-width: 520px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.6;
}

.host-character {
  width: min(100%, 460px);
  max-height: 540px;
  justify-self: center;
  object-fit: contain;
}

.chat-panel {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  grid-template-rows: 68px 122px minmax(0, 1fr) auto auto;
  width: min(var(--panel-width), calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid #cbd6ce;
  border-radius: var(--panel-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 1;
  transform: translateX(0);
  transition: opacity 180ms ease, transform 180ms ease, height 220ms ease;
}

.chat-panel.is-opening,
.chat-panel.is-closing {
  opacity: 0;
  transform: translateX(18px);
}

.chat-header {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 8px 10px 8px 14px;
  background: var(--lapig-dark-green);
  color: #ffffff;
}

.chat-logo {
  width: 70px;
  height: 48px;
  object-fit: contain;
  background: #ffffff;
}

.chat-heading {
  min-width: 0;
}

.chat-heading h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.chat-heading p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  color: #e6f1e8;
  font-size: 0.75rem;
  line-height: 1.3;
}

.chat-heading p span {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--lapig-yellow);
}

.window-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

#minimizeButton {
  display: none !important;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #ffffff;
  font-size: 1.45rem;
  line-height: 1;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.cberino-presence {
  position: relative;
  display: grid;
  min-height: 122px;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #fbfcf9;
}

.cberino-presence::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 8px;
  background: var(--lapig-yellow);
}

#cberinoImage {
  width: 150px;
  height: 114px;
  padding: 4px;
  object-fit: contain;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 140ms ease, transform 180ms ease;
}

#cberinoImage.is-changing {
  opacity: 0;
  transform: translateY(4px) scale(0.97);
}

#cberinoImage.motion-thinking {
  animation: cberino-float 1.6s ease-in-out infinite;
}

#cberinoImage.motion-success,
#cberinoImage.motion-celebrating {
  animation: cberino-bounce 420ms ease-out;
}

#cberinoImage.motion-idle {
  animation: cberino-idle 3.2s ease-in-out infinite;
}

#cberinoImage.motion-confused {
  animation: cberino-confused 900ms ease-in-out infinite;
}

#cberinoImage.motion-environment {
  animation: cberino-environment 3.4s ease-in-out infinite;
}

#cberinoImage.motion-love {
  animation: cberino-love 1.6s ease-in-out infinite;
}

.message-history {
  min-height: 0;
  padding: 20px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #9ba99e transparent;
  scroll-padding-bottom: 16px;
}

.message {
  width: fit-content;
  max-width: 86%;
  margin: 0;
  margin-bottom: 16px;
  padding: 11px 13px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.message-author {
  display: block;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 800;
}

.message p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-assistant {
  margin-right: auto;
  border: 1px solid var(--line);
  background: var(--lapig-background);
  color: var(--ink);
}

.message-user {
  margin-left: auto;
  background: var(--lapig-dark-green);
  color: #ffffff;
}

.message-error {
  border-color: #e4b9ad;
  background: #fff4f1;
  color: #702612;
}

.typing-indicator {
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 6px 22px 10px;
  background: var(--surface);
}

.typing-indicator:not([hidden]) {
  display: flex;
}

.typing-indicator > span:not(.sr-only) {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lapig-green);
  animation: typing 900ms ease-in-out infinite;
}

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

.typing-indicator > span:nth-child(4) {
  animation-delay: 240ms;
}

.message-form {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.message-form > label {
  display: block;
  margin-bottom: 7px;
  color: var(--lapig-dark-green);
  font-size: 0.875rem;
  font-weight: 800;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  gap: 8px;
  padding: 7px;
  border: 1px solid #9aaba0;
  border-radius: 8px;
  background: #ffffff;
}

.composer:focus-within {
  border-color: var(--lapig-green);
  box-shadow: 0 0 0 2px rgba(18, 121, 64, 0.15);
}

.composer.has-error {
  border-color: var(--lapig-red);
}

#messageInput {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  padding: 9px 8px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1rem;
  line-height: 1.45;
}

#messageInput::placeholder {
  color: #6d7970;
}

.send-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--lapig-yellow);
  color: #153b1d;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
}

.send-button:hover:not(:disabled) {
  background: #ddb100;
  transform: translateY(-1px);
}

.send-button:disabled {
  opacity: 0.55;
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 23px;
  padding: 5px 2px 0;
  color: var(--muted);
  font-size: 0.75rem;
}

#formError {
  margin: 0;
  color: #8d2f17;
  font-weight: 700;
}

#characterCount {
  margin-left: auto;
  white-space: nowrap;
}

.mock-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.chat-launcher {
  position: fixed;
  z-index: 18;
  right: 20px;
  bottom: 20px;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  padding: 4px;
  border: 3px solid var(--lapig-dark-green);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.chat-launcher img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: transparent;
  object-fit: contain;
}

.chat-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 28px rgba(23, 34, 26, 0.24);
}

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

@keyframes cberino-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes cberino-bounce {
  0%, 100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.05);
  }
}

@keyframes cberino-idle {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-3px) rotate(-1deg);
  }
}

@keyframes cberino-confused {
  0%, 100% {
    transform: rotate(0deg);
  }
  35% {
    transform: rotate(-3deg);
  }
  70% {
    transform: rotate(3deg);
  }
}

@keyframes cberino-environment {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-2px) rotate(1deg);
  }
}

@keyframes cberino-love {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.045);
  }
}

@media (max-width: 900px) {
  .host-surface {
    padding-right: min(44vw, var(--panel-width));
  }

  .host-stage {
    grid-template-columns: 1fr;
  }

  .host-character {
    display: none;
  }

  .host-copy h1 {
    font-size: 3rem;
  }
}

@media (max-width: 600px) {
  .host-surface {
    display: none;
  }

  .chat-panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    grid-template-rows: 68px 102px minmax(0, 1fr) auto auto;
    border: 0;
    border-radius: 0;
  }

  .chat-header {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 8px;
    padding-left: 10px;
  }

  .chat-logo {
    width: 60px;
    height: 44px;
  }

  .window-actions {
    gap: 0;
  }

  .icon-button {
    width: 38px;
  }

  .cberino-presence {
    min-height: 102px;
  }

  #cberinoImage {
    width: 132px;
    height: 96px;
  }

  .message-history {
    padding: 16px 14px;
  }

  .message {
    max-width: 91%;
  }

  .message-form {
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }

  .chat-launcher {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-height: 650px) {
  .chat-panel {
    grid-template-rows: 68px 82px minmax(0, 1fr) auto auto;
  }

  .cberino-presence {
    min-height: 82px;
  }

  #cberinoImage {
    width: 112px;
    height: 78px;
  }

  .message-history {
    padding-top: 12px;
    padding-bottom: 12px;
  }
}

@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;
  }
}
