* {
  box-sizing: border-box;
}

:root {
  --ivory: #fffaf7;
  --soft-white: #fffdfb;
  --blush: #f6dfe4;
  --blush-deep: #e9a0b0;
  --rose: #dd8197;
  --text: #4e3c42;
  --muted: #9a7e86;
  --border: #ecd8dd;
  --shadow: 0 24px 70px rgba(91, 58, 68, 0.15);
}

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

body {
  min-height: 100vh;
  padding: 22px;

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: var(--text);

  background:
    radial-gradient(
      circle at top left,
      #fff9f4 0%,
      #f7e7e7 45%,
      #efe5e2 100%
    );
}

button,
textarea,
select {
  font: inherit;
}

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

button:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}


/* -------------------------------------------------- */
/* APPLICATION SHELL                                  */
/* -------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 34% 66%;
  grid-template-rows: minmax(0, 1fr);

  width: min(1420px, 100%);
  height: calc(100dvh - 44px);
  max-height: calc(100dvh - 44px);
  min-height: 0;

  margin: 0 auto;
  overflow: hidden;

  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 34px;

  background: var(--soft-white);
  box-shadow: var(--shadow);
}


/* -------------------------------------------------- */
/* LEFT SCENIC PANEL                                  */
/* -------------------------------------------------- */

.scene-panel {
  position: relative;
  min-width: 0;
  min-height: 0;

  overflow: hidden;
  isolation: isolate;

  background: #f5dde2;
}

.landscape-background {
  position: absolute;
  inset: 0;
  z-index: 0;

  background-image:
    url("assets/mechat-bridge-hero.png");

  background-size: cover;
  background-position: 5% 25%;
  background-repeat: no-repeat;

  transform: scale(1.015);
}

.scene-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;

  pointer-events: none;

  background:
    linear-gradient(
      180deg,
      rgba(255, 251, 248, 0.02) 0%,
      rgba(255, 244, 247, 0.05) 60%,
      rgba(255, 244, 247, 0.22) 100%
    ),
    linear-gradient(
      90deg,
      rgba(255, 250, 247, 0.06) 0%,
      rgba(255, 250, 247, 0.01) 70%,
      rgba(255, 250, 247, 0.14) 100%
    );
}


/* -------------------------------------------------- */
/* BRAND CARD — FULL-WIDTH LOWER PINK AREA            */
/* -------------------------------------------------- */

.brand-card {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;

    height: 65px;

    display: flex;
    align-items: center;

    padding: 0 22px;
    gap: 18px;

    background: rgba(255,248,248,.94);

    border-top: 1px solid rgba(255,255,255,.7);

    z-index: 20;
}

.brand-flower {
    width: 58px;
    height: 58px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 18px;

    background: rgba(255,255,255,.65);

    font-size: 28px;
}

.brand-card > div:last-child{
    flex:1;
    min-width:0;
}

.brand-name{
    margin:0;

    font-size:18px;
    font-weight:700;

    line-height:1.1;
}

.brand-description{
    margin-top:4px;

    font-size:12px;

    color:#8b7178;

    white-space:normal;
    line-height:1.35;

    max-width:100%;
}

/* -------------------------------------------------- */
/* STATUS CARD                                        */
/* -------------------------------------------------- */

.status-card {
  position: absolute;
  z-index: 5;

  top: 121px;
  left: 34px;

  display: flex;
  align-items: center;
  gap: 9px;

  padding: 9px 14px;

  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;

  background: rgba(255, 250, 247, 0.66);

  color: #6c555c;
  font-size: 13px;

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.online-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;
  background: #58be7b;

  box-shadow:
    0 0 0 4px rgba(88, 190, 123, 0.12);
}

.scene-caption {
  position: absolute;
  z-index: 5;

  left: 38px;
  bottom: 125px;

  max-width: 300px;

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size: 21px;
  font-style: italic;
  line-height: 1.35;

  color: #6b5057;

  text-shadow:
    0 1px 3px rgba(255, 255, 255, 0.85);
}


/* -------------------------------------------------- */
/* SAKURA PETALS                                      */
/* -------------------------------------------------- */

.petal-layer {
  position: absolute;
  inset: 0;
  z-index: 4;

  overflow: hidden;
  pointer-events: none;
}

.petal {
  position: absolute;
  top: -40px;

  z-index: 4;

  pointer-events: none;

  font-size: 18px;
  line-height: 1;

  opacity: 0;

  filter:
    drop-shadow(
      0 3px 5px rgba(195, 87, 118, 0.16)
    );

  animation:
    petalFall var(--duration, 13s)
    cubic-bezier(0.2, 0.5, 0.4, 1)
    forwards;
}

@keyframes petalFall {
  0% {
    transform:
      translate3d(0, -20px, 0)
      rotate(0deg)
      scale(0.8);

    opacity: 0;
  }

  10% {
    opacity: 0.85;
  }

  45% {
    transform:
      translate3d(
        var(--drift, 35px),
        45vh,
        0
      )
      rotate(170deg)
      scale(1);
  }

  100% {
    transform:
      translate3d(
        calc(var(--drift, 35px) * 0.35),
        105vh,
        0
      )
      rotate(390deg)
      scale(0.9);

    opacity: 0;
  }
}


/* -------------------------------------------------- */
/* CHAT PANEL                                         */
/* -------------------------------------------------- */

.chat-panel {
  display: flex;
  flex-direction: column;

  min-width: 0;
  min-height: 0;

  width: 100%;
  height: 100%;
  max-height: 100%;

  overflow: hidden;

  background:
    rgba(255, 253, 251, 0.98);
}


/* -------------------------------------------------- */
/* CHAT HEADER                                        */
/* -------------------------------------------------- */

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;

  flex: 0 0 auto;

  height: 86px;
  min-height: 86px;

  padding: 18px 25px;

  border-bottom: 1px solid var(--border);

  background:
    rgba(255, 250, 247, 0.90);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-companion {
  position: relative;

  width: 44px;
  height: 44px;

  flex: 0 0 auto;

  border: 1px solid #efd7dd;
  border-radius: 15px;

  background:
    linear-gradient(
      145deg,
      #ffffff,
      #f2d7de
    );

  box-shadow:
    0 6px 18px rgba(100, 63, 73, 0.08);
}

.header-eye {
  position: absolute;
  top: 14px;

  width: 5px;
  height: 8px;

  border-radius: 50%;
  background: #745c62;

  animation: blink 5.5s infinite;
}

.header-eye:first-child {
  left: 13px;
}

.header-eye:nth-child(2) {
  right: 13px;
}

.header-mouth {
  position: absolute;

  left: 50%;
  bottom: 10px;

  width: 10px;
  height: 5px;

  transform: translateX(-50%);

  border-bottom: 2px solid #745c62;
  border-radius: 0 0 10px 10px;
}

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

.header-text h1 {
  margin: 0;

  font-size: 18px;
  font-weight: 750;
}

.header-text p {
  margin: 3px 0 0;

  color: var(--muted);
  font-size: 12px;
}

.header-button {
  width: 42px;
  height: 42px;

  margin-left: auto;

  border: 0;
  border-radius: 14px;

  background: #f7e7eb;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.header-button:hover {
  transform: translateY(-1px);
  background: #f2d9df;
}


/* -------------------------------------------------- */
/* MESSAGES                                           */
/* -------------------------------------------------- */

.messages {
  flex: 1 1 auto;

  width: 100%;
  height: 0;
  min-height: 0;

  padding: 30px 28px 14px;

  overflow-y: auto;
  overflow-x: hidden;

  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;

  margin-bottom: 21px;
}

.user-row {
  justify-content: flex-end;
}

.message-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-row .message-column {
  align-items: flex-end;
}

.bubble {
  max-width: min(650px, 77%);

  padding: 15px 18px;

  font-size: 15px;
  line-height: 1.5;

  box-shadow:
    0 9px 26px rgba(85, 56, 64, 0.065);
}

.assistant-bubble {
  border: 1px solid var(--border);
  border-radius: 22px 22px 22px 7px;

  background: #ffffff;
}

.user-bubble {
  border-radius: 22px 22px 7px 22px;

  background:
    linear-gradient(
      145deg,
      #f4ccd5,
      #efb8c5
    );

  color: #4b363c;
}

.message-time {
  padding: 0 5px;

  color: #aa9097;
  font-size: 11px;
}


/* -------------------------------------------------- */
/* COMPANION                                          */
/* -------------------------------------------------- */

.companion {
  display: grid;
  place-items: center;

  width: 50px;
  height: 50px;

  flex: 0 0 auto;

  border: 1px solid #ecd2d8;
  border-radius: 18px;

  background:
    linear-gradient(
      145deg,
      #ffffff,
      #f2d6dd
    );

  box-shadow:
    0 8px 24px rgba(100, 60, 70, 0.12);

  transition:
    transform 0.3s ease;
}

.face {
  position: relative;

  width: 32px;
  height: 26px;
}

.eye {
  position: absolute;
  top: 5px;

  width: 6px;
  height: 10px;

  border-radius: 50%;
  background: #665158;

  animation: blink 5.5s infinite;
}

.eye-left {
  left: 6px;
}

.eye-right {
  right: 6px;
}

.mouth {
  position: absolute;

  left: 50%;
  bottom: 2px;

  width: 12px;
  height: 6px;

  transform: translateX(-50%);

  border-bottom: 2px solid #665158;
  border-radius: 0 0 12px 12px;
}

@keyframes blink {
  0%,
  44%,
  48%,
  100% {
    transform: scaleY(1);
  }

  46% {
    transform: scaleY(0.08);
  }
}

.companion[data-state="thinking"] {
  animation:
    companionThinking 1.35s
    ease-in-out
    infinite;
}

@keyframes companionThinking {
  50% {
    transform:
      translateY(-3px)
      rotate(2deg);
  }
}

.companion[data-state="speaking"] .mouth {
  animation:
    companionSpeaking 0.22s
    ease-in-out
    infinite alternate;
}

@keyframes companionSpeaking {
  from {
    width: 9px;
    height: 3px;
  }

  to {
    width: 12px;
    height: 9px;

    border: 1px solid #665158;
    border-radius: 50%;

    background: #efd0d8;
  }
}


/* -------------------------------------------------- */
/* TYPING INDICATOR                                   */
/* -------------------------------------------------- */

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;

  height: 22px;
}

.typing-dots span {
  width: 6px;
  height: 6px;

  border-radius: 50%;
  background: #b899a1;

  animation:
    typingDot 1s infinite;
}

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

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

@keyframes typingDot {
  50% {
    transform: translateY(-4px);
    opacity: 0.5;
  }
}


/* -------------------------------------------------- */
/* COMPOSER                                           */
/* -------------------------------------------------- */

.composer {
  position: relative;
  z-index: 20;

  flex: 0 0 auto;
  flex-shrink: 0;

  padding: 14px 24px 22px;

  border-top:
    1px solid rgba(237, 217, 221, 0.72);

  background:
    rgba(255, 253, 251, 0.98);
}

.speech-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;

  padding:
    10px
    10px
    10px
    18px;

  border: 1px solid #e6cdd4;
  border-radius: 25px 25px 25px 9px;

  background: #ffffff;

  box-shadow:
    0 11px 34px rgba(103, 67, 75, 0.09);

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.speech-input:focus-within {
  border-color: #dd99aa;

  box-shadow:
    0 12px 36px rgba(220, 134, 155, 0.17);
}

textarea {
  flex: 1;

  min-width: 0;
  min-height: 30px;
  max-height: 130px;

  padding: 7px 0;

  resize: none;

  border: 0;
  outline: 0;

  background: transparent;

  color: var(--text);

  line-height: 1.42;
}

textarea::placeholder {
  color: #af969d;
}

.composer-button,
.send-button {
  width: 43px;
  height: 43px;

  flex: 0 0 auto;

  border: 0;
  border-radius: 15px;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.composer-button {
  background: #f8e9ed;
}

.send-button {
  color: #ffffff;
  font-size: 19px;

  background:
    linear-gradient(
      145deg,
      #ed9caf,
      #dc7f95
    );
}

.composer-button:hover,
.send-button:hover {
  transform: translateY(-1px);
}

.composer-button.listening {
  background: #f1c1cc;

  animation:
    microphonePulse 1s infinite;
}

@keyframes microphonePulse {
  50% {
    box-shadow:
      0 0 0 8px
      rgba(233, 149, 168, 0.13);
  }
}

.composer-note {
  margin-top: 8px;

  text-align: center;

  color: #ae959b;
  font-size: 11px;
}


/* -------------------------------------------------- */
/* TABLET                                             */
/* -------------------------------------------------- */

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 38% 62%;
  }

  .scene-caption {
    left: 24px;

    font-size: 18px;
  }
}


/* -------------------------------------------------- */
/* MOBILE                                             */
/* -------------------------------------------------- */

@media (max-width: 820px) {
  body {
    padding: 0;
  }

  .app-shell {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;

    grid-template-columns: 1fr;

    border: 0;
    border-radius: 0;
  }

  .scene-panel {
    display: none;
  }

  .chat-panel {
    height: 100dvh;
    max-height: 100dvh;
  }

  .chat-header {
    height: 76px;
    min-height: 76px;
  }

  .messages {
    padding:
      20px
      16px
      8px;
  }

  .composer {
    padding:
      12px
      14px
      16px;
  }

  .bubble {
    max-width: 82%;
  }
}


/* -------------------------------------------------- */
/* REDUCED MOTION                                     */
/* -------------------------------------------------- */

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