:root {
  color-scheme: light;
  --ink: #18202c;
  --muted: #667085;
  --line: #d8dde7;
  --paper: #f7f8fb;
  --panel: #ffffff;
  --accent: #1f8a70;
  --accent-dark: #126754;
  --rose: #e8628c;
  --sun: #f1b84b;
  --blue: #4b7bec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: linear-gradient(135deg, #f4f8f5 0%, #f9f3f5 45%, #eef4ff 100%);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

.project-nav {
  width: min(1120px, calc(100vw - 32px));
  min-height: 48px;
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(216, 221, 231, 0.9);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 34px rgba(27, 42, 68, 0.1);
  backdrop-filter: blur(18px);
}

.project-nav a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.project-nav a:hover,
.project-nav a:focus-visible {
  background: #eef2f7;
  outline: none;
}

.brand-link {
  background: var(--ink);
  color: #fff !important;
}

.project-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  height: calc(100vh - 78px);
  height: calc(100dvh - 78px);
  min-height: 0;
  margin: 10px auto 14px;
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.character-stage,
.chat-panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(216, 221, 231, 0.9);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(27, 42, 68, 0.12);
  backdrop-filter: blur(18px);
}

.character-stage {
  min-height: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.topbar,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.chat-header button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 20px;
}

.avatar-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 138, 112, 0.08), transparent),
    linear-gradient(180deg, #fff, #f6f7fb);
  overflow: hidden;
  position: relative;
}

.avatar-wrap img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(24, 32, 44, 0.13));
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.avatar-wrap.thinking img {
  animation: thinkingFloat 5.2s ease-in-out infinite;
}

@keyframes thinkingFloat {
  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(1px, -2px);
  }

  65% {
    transform: translate(-1px, 1px);
  }
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(31, 138, 112, 0.28);
  border-radius: 8px;
  background: #edf7f4;
}

.picker-head h2 {
  font-size: 17px;
  margin-bottom: 4px;
}

.picker-head p {
  color: var(--muted);
  font-size: 13px;
}

.character-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.character-choice {
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.character-choice:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(31, 138, 112, 0.12);
}

.character-choice strong {
  display: block;
  margin-bottom: 4px;
}

.character-choice span {
  color: var(--muted);
  font-size: 12px;
}

.character-choice.active {
  border-color: var(--accent);
  background: #f2fbf8;
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 8px 20px rgba(31, 138, 112, 0.14);
}

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

.chat-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.chat-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.messages {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  width: fit-content;
  max-width: min(78%, 720px);
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.assistant {
  align-self: flex-start;
  background: #edf7f4;
  border: 1px solid #cae7df;
}

.message.user {
  align-self: flex-end;
  background: #f4efff;
  border: 1px solid #ded2f4;
}

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

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: none;
  padding: 12px;
  line-height: 1.5;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 138, 112, 0.14);
}

.composer button {
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.composer button:hover {
  background: var(--accent-dark);
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .project-nav {
    width: min(100vw - 20px, 640px);
    min-height: 88px;
    align-items: stretch;
    flex-direction: column;
    margin-top: 10px;
  }

  .project-links {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .brand-link {
    width: 100%;
  }

  .app-shell {
    width: min(100vw - 20px, 640px);
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    margin: 10px auto;
    overflow: visible;
  }

  .character-stage {
    overflow: visible;
  }

  .avatar-wrap {
    min-height: clamp(220px, 42vh, 340px);
  }

  .chat-panel {
    height: min(72vh, 620px);
    min-height: 520px;
  }

  .character-picker {
    grid-template-columns: 1fr;
  }

  .messages {
    min-height: 0;
  }

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

  .composer button {
    min-height: 44px;
  }

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