:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  background: #141217;
  color: #f1e7e6;
  --surface: #1c181e;
  --line: #3b2b36;
  --muted: #b6a5b1;
  --accent: #f1b8a5;
  --dark-accent: #2e1920;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid #f1b8a5; outline-offset: 4px; }
[hidden] { display: none !important; }

.workspace {
  width: min(1240px, 100% - 64px);
  margin: 0 auto;
}

.site-header {
  display: flex;
  height: 86px;
  justify-content: space-between;
  align-items: center;
}

.wordmark, .account { display: flex; align-items: center; }
.wordmark { gap: 11px; font-size: 19px; font-weight: 650; }
.account { color: var(--muted); gap: 22px; font-size: 13px; }
.account button { padding: 0; border: 0; background: transparent; color: inherit; }
.account a:hover, .account button:hover, .back-link:hover { color: var(--accent); }

.identity-mark {
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: #402834;
  color: #f6bcac;
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
}

.companion {
  display: grid;
  grid-template-columns: 1fr .93fr;
  gap: 16px;
  height: clamp(540px, calc(100dvh - 121px), 810px);
  margin-bottom: 30px;
}

.portrait-panel, .chat-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
}

.portrait-panel { position: relative; isolation: isolate; background: #262028; }
.avatar, .portrait-shade { position: absolute; inset: 0; }
.avatar > img, .avatar > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
}

.portrait-shade {
  pointer-events: none;
  background: linear-gradient(180deg, #13101700 49%, #140e1770 74%, #140e17f5);
}

.portrait-footer {
  position: absolute;
  right: 27px;
  bottom: 25px;
  left: 27px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 15px;
}

.portrait-label { display: grid; gap: 7px; }
.portrait-label strong { font-size: clamp(26px, 4vw, 46px); font-weight: 550; line-height: 1; }
.portrait-label span { color: #f8e5e3; font-size: 13px; }

.mic-button {
  display: grid;
  flex: none;
  width: 60px;
  height: 60px;
  place-items: center;
  color: var(--dark-accent);
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 23px #f1b8a54d;
  transition: transform .2s, box-shadow .2s;
}

.mic-button:hover { transform: translateY(-2px); }
.mic-button[aria-pressed="true"] { background: #ffceb8; box-shadow: 0 0 0 7px #f1b8a532, 0 0 23px #f1b8a560; }
.mic-icon { width: 17px; height: 16px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 9px 9px; position: relative; top: 1px; }
.mic-icon::before {
  content: "";
  width: 7px;
  height: 14px;
  background: currentColor;
  border-radius: 5px;
  position: absolute;
  top: -5px;
  left: 3px;
}

.mic-icon::after { content: ""; height: 5px; width: 2px; background: currentColor; position: absolute; top: 14px; left: 5.5px; }
.chat-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; background: var(--surface); }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 21px; border-bottom: 1px solid var(--line); }
.chat-header h1 { margin: 0; font-size: 17px; font-weight: 650; }
.voice-setting {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #211a22;
  border-radius: 20px;
  font-size: 12px;
}

.voice-setting i { width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.voice-setting[aria-pressed="true"] { color: #fac3af; background: #38252e; border-color: #634451; }
.messages { min-height: 0; overflow: auto; padding: 22px 20px; scrollbar-color: #604653 transparent; }
.message { display: flex; align-items: start; margin-bottom: 13px; gap: 8px; }
.message img { width: 29px; height: 29px; object-fit: cover; object-position: center 38%; border-radius: 50%; flex: none; }
.message p {
  max-width: 82%;
  margin: 0;
  padding: 10px 13px;
  border-radius: 5px 14px 14px;
  background: #30242e;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user { justify-content: end; }
.message.user p { color: #f5e0db; background: #573646; border-radius: 14px 5px 14px 14px; }
.message[data-pending] p { color: var(--muted); }
.composer { display: flex; align-items: end; gap: 8px; border: 1px solid #493543; border-radius: 16px; margin: 0 17px 17px; padding: 7px; background: #271e27; }
.composer:focus-within { border-color: #a16a76; }
.composer textarea {
  display: block;
  flex: 1;
  width: 0;
  height: auto;
  min-height: 41px;
  max-height: 130px;
  field-sizing: content;
  padding: 10px 9px;
  resize: none;
  overflow: auto;
  border: 0;
  outline: none;
  color: inherit;
  background: transparent;
  font-size: 16px;
  line-height: 1.35;
}

.composer textarea::placeholder { color: var(--muted); }
.send-button, .primary {
  color: var(--dark-accent);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  font-weight: 650;
}

.send-button { width: 41px; height: 41px; flex: none; font-size: 24px; line-height: 1; }
.send-button:not(:disabled):hover, .primary:hover { background: #ffd0bd; }
.chat-error { grid-row: 3; padding: 0 21px; }
.chat-error, .form-error { color: #ffc6cc; font-size: 13px; }
.composer { grid-row: 4; }

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100svh;
  background: radial-gradient(ellipse at 50% 10%, #3d2937, transparent 66%), #141217;
  padding: 25px;
}

.auth-card { width: min(100%, 400px); border: 1px solid #533d4c; border-radius: 24px; padding: 31px; background: #211a22; }
.auth-card .identity-mark { width: 42px; }
.auth-card h1 { margin: 16px 0 7px; font-size: 26px; font-weight: 650; }
.auth-subtitle { margin: 0 0 23px; color: var(--muted); font-size: 14px; }
.auth-form { display: grid; gap: 14px; padding: 8px 0 0; }
.auth-form label { display: grid; gap: 6px; color: #e2d1dc; font-size: 13px; }
.auth-form input { width: 100%; border: 1px solid #604957; padding: 11px 12px; border-radius: 9px; background: #2a202a; color: #fff4f4; font-size: 16px; }
.auth-form .primary { padding: 10px; margin-top: 6px; }
.form-error, .form-success { margin: 0; }
.form-success { color: #d2e6bd; font-size: 13px; }
.back-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .workspace { width: calc(100% - 24px); }
  .site-header { height: 62px; }
  .companion { display: flex; flex-direction: column; height: auto; gap: 10px; margin-bottom: 12px; }
  .portrait-panel { height: 34svh; min-height: 205px; }
  .chat-panel { min-height: 340px; height: calc(66svh - 84px); }
  .portrait-panel, .chat-panel { border-radius: 18px; }
  .portrait-footer { inset: auto 15px 15px; }
  .mic-button { width: 50px; height: 50px; }
  .chat-header { padding: 12px 14px; }
  .messages { padding: 13px; }
  .composer { margin: 0 10px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
