:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #617083;
  --line: #dce3ea;
  --accent: #0f766e;
  --accent-strong: #0a5c56;
  --soft: #edf5f4;
  --shadow: 0 14px 36px rgba(22, 33, 45, 0.08);
}

.fibo-live2d-avatar {
  --look-x: 0;
  --look-y: 0;
  width: 148px;
  height: 148px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  background: #fff7ea;
  box-shadow: 0 12px 28px rgba(15, 54, 61, 0.16);
  transform:
    translate(calc(var(--look-x) * 2px), calc(var(--look-y) * 1px))
    rotate(calc(var(--look-x) * 1.5deg));
  transition: transform 120ms ease-out;
}

.fibo-live2d-avatar::after {
  inset: 0;
  border-radius: inherit;
}

.fibo-live2d-base,
.fibo-live2d-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.fibo-live2d-frame {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.fibo-live2d-frame.on {
  opacity: 1;
}

.fibo-live2d-avatar.caught {
  box-shadow: 0 14px 30px rgba(80, 42, 61, 0.22);
}

@media (max-width: 800px) {
  .fibo-live2d-avatar {
    width: 112px;
    height: 112px;
  }
}

.fibo-card-avatar-only {
  justify-content: center;
  width: 100%;
}

.fibo-card-avatar-only .fibo-live2d-avatar {
  flex: 0 0 auto;
}

.message-row.assistant > .message-avatar {
  display: block !important;
}

.fibo-card-avatar-only {
  justify-content: center;
  width: 100%;
}

.fibo-card-avatar-only .fibo-live2d-avatar {
  flex: 0 0 auto;
}

.message-row.assistant > .message-avatar {
  display: block !important;
}

.messages {
  gap: 14px;
  padding: 18px 20px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: min(760px, 100%);
}

.message-row.assistant {
  align-self: flex-start;
}

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

.message-row.system {
  align-self: center;
  justify-content: center;
  max-width: min(640px, 94%);
}

.message-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: #fff8ee;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.message-bubble {
  width: fit-content;
  max-width: min(680px, 100%);
  padding: 11px 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.message-row.assistant .message-bubble {
  border-bottom-left-radius: 4px;
  background: #ffffff;
}

.message-row.user .message-bubble {
  color: #ffffff;
  border-color: #0f766e;
  background: #0f766e;
  border-bottom-right-radius: 4px;
}

.message-row.system .message-bubble {
  color: var(--muted);
  background: #f8fafc;
  border-radius: 999px;
  text-align: center;
}

.message-row.temporary .message-bubble {
  color: var(--muted);
}

@media (max-width: 800px) {
  .messages {
    padding: 14px;
  }

  .message-row {
    max-width: 100%;
  }

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

  .message-bubble {
    max-width: calc(100vw - 104px);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-link {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 6px;
  background: #e8eef3;
  color: var(--text);
  text-decoration: none;
}

.language-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 4px;
}

.lang-option {
  min-height: 34px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.lang-option:hover {
  background: #edf5f4;
  color: var(--text);
}

.lang-option.active {
  background: var(--accent);
  color: white;
}

.secondary {
  background: #e8eef3;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.chat-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  width: min(1180px, calc(100% - 28px));
  height: calc(100vh - 28px);
  margin: 14px auto;
}

.sidebar,
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.note strong {
  color: var(--text);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
}

.fibo-stage {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
  padding: 14px 18px 12px;
}

.fibo-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.fibo-avatar {
  --eye-x: 0px;
  --eye-y: 0px;
  position: relative;
  flex: 0 0 auto;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background: #e9eef2;
  box-shadow: 0 10px 24px rgba(15, 54, 61, 0.18);
  transform: translateZ(0);
}

.fibo-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: 51% 38%;
}

.fibo-anime-avatar {
  overflow: visible;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.98), rgba(238, 247, 246, 0.98) 68%),
    #edf5f4;
}

.fibo-anime {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 128px;
  height: 128px;
  transform: translate(-50%, -50%);
  overflow: visible;
}

.fibo-anime .tail,
.fibo-anime .head,
.fibo-anime .ear,
.fibo-anime .face-fluff,
.fibo-anime .body {
  stroke: #56636d;
  stroke-width: 4;
  stroke-linejoin: round;
}

.fibo-anime .head,
.fibo-anime .ear,
.fibo-anime .body {
  fill: #f7f4ec;
}

.fibo-anime .face-fluff,
.fibo-anime .muzzle {
  fill: #fffdf8;
  stroke: #d7d3c8;
  stroke-width: 2;
}

.fibo-anime .ear-inner {
  fill: #f4b8c6;
  stroke: none;
}

.fibo-anime .forehead-mark {
  fill: #9a9087;
  opacity: 0.95;
}

.fibo-anime .cheek-mark,
.fibo-anime .whisker,
.fibo-anime .mouth,
.fibo-anime .tail {
  fill: none;
  stroke: #6f6a64;
  stroke-linecap: round;
}

.fibo-anime .cheek-mark {
  stroke-width: 4;
  opacity: 0.7;
}

.fibo-anime .whisker,
.fibo-anime .mouth {
  stroke-width: 2.7;
}

.fibo-anime .nose {
  fill: #e98ca0;
  stroke: #b86c7b;
  stroke-width: 1.5;
}

.fibo-anime .outfit {
  fill: #595886;
  stroke: #3f4069;
  stroke-width: 3;
  stroke-linejoin: round;
}

.fibo-anime .collar {
  fill: none;
  stroke: #f8f0dc;
  stroke-width: 5;
  stroke-linecap: round;
}

.fibo-avatar::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(15, 118, 110, 0.2);
  pointer-events: none;
}

.fibo-eye {
  position: absolute;
  width: 19px;
  height: 23px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 63% 24%, #ffffff 0 3px, transparent 4px),
    radial-gradient(circle at 50% 56%, #26313a 0 8px, #111920 9px 100%);
  border: 2px solid #4f5d66;
  box-shadow: 0 2px 5px rgba(21, 35, 42, 0.18);
  pointer-events: none;
}

.fibo-eye span {
  position: absolute;
  left: 5px;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  opacity: 0.95;
  transform: translate(var(--eye-x), var(--eye-y));
  transition: transform 80ms linear;
}

.fibo-eye-left {
  left: 43px;
  top: 43px;
}

.fibo-eye-right {
  left: 70px;
  top: 43px;
}

.fibo-paw {
  position: absolute;
  right: -18px;
  bottom: 10px;
  width: 42px;
  height: 54px;
  border-radius: 22px 22px 18px 18px;
  background:
    radial-gradient(circle at 50% 78%, #ef9eb1 0 5px, transparent 6px),
    radial-gradient(circle at 32% 55%, #f3b2bf 0 4px, transparent 5px),
    radial-gradient(circle at 52% 48%, #f3b2bf 0 4px, transparent 5px),
    radial-gradient(circle at 70% 55%, #f3b2bf 0 4px, transparent 5px),
    linear-gradient(160deg, #ffffff 0%, #eef2f3 100%);
  border: 1px solid rgba(166, 177, 183, 0.5);
  box-shadow: 0 8px 16px rgba(15, 54, 61, 0.2);
  opacity: 0;
  transform: rotate(24deg) translate(20px, 16px) scale(0.7);
  transform-origin: 50% 100%;
  transition: transform 180ms ease, opacity 160ms ease;
  pointer-events: none;
}

.fibo-avatar.pounce .fibo-paw {
  opacity: 1;
  transform: rotate(-22deg) translate(2px, -28px) scale(1);
}

.fibo-bubble {
  position: relative;
  min-height: 48px;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
  color: var(--text);
  line-height: 1.55;
  box-shadow: 0 8px 22px rgba(22, 33, 45, 0.06);
  overflow-wrap: anywhere;
}

.fibo-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 28px;
  width: 14px;
  height: 14px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  transform: rotate(45deg);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
}

.message {
  max-width: min(720px, 88%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: #0f766e;
  color: white;
  border-color: #0f766e;
}

.message.assistant {
  align-self: flex-start;
  background: #fbfcfd;
}

.message.system {
  align-self: center;
  max-width: 620px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.composer button {
  align-self: end;
  min-width: 86px;
}

@media (max-width: 800px) {
  .chat-shell {
    height: auto;
    min-height: calc(100vh - 20px);
    grid-template-columns: 1fr;
    margin: 10px auto;
  }

  .chat-panel {
    min-height: 620px;
  }

  .fibo-card {
    align-items: flex-start;
  }

  .fibo-avatar {
    width: 92px;
    height: 92px;
  }

  .fibo-anime {
    width: 101px;
    height: 101px;
  }

  .fibo-eye {
    width: 15px;
    height: 18px;
  }

  .fibo-eye span {
    left: 4px;
    top: 5px;
    width: 5px;
    height: 5px;
  }

  .fibo-eye-left {
    left: 34px;
    top: 34px;
  }

  .fibo-eye-right {
    left: 55px;
    top: 34px;
  }

  .fibo-bubble {
    font-size: 14px;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 96%;
  }
}

.fibo-live2d-avatar {
  --look-x: 0;
  --look-y: 0;
  width: 148px;
  height: 148px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  background: #fff7ea;
  box-shadow: 0 12px 28px rgba(15, 54, 61, 0.16);
  transform:
    translate(calc(var(--look-x) * 2px), calc(var(--look-y) * 1px))
    rotate(calc(var(--look-x) * 1.5deg));
  transition: transform 120ms ease-out;
}

.fibo-live2d-avatar::after {
  inset: 0;
  border-radius: inherit;
}

.fibo-live2d-base,
.fibo-live2d-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.fibo-live2d-frame {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.fibo-live2d-frame.on {
  opacity: 1;
}

.fibo-live2d-avatar.caught {
  box-shadow: 0 14px 30px rgba(80, 42, 61, 0.22);
}

@media (max-width: 800px) {
  .fibo-live2d-avatar {
    width: 112px;
    height: 112px;
  }
}
