:root {
  --ink: #202a24;
  --soft: #687169;
  --paper: #eee6d5;
  --light: #f8f3e8;
  --line: rgba(32, 42, 36, .14);
  --red: #a54130;
  --green: #5e7963;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: radial-gradient(circle at 80% 4%, rgba(165,65,48,.11), transparent 30rem), linear-gradient(140deg, #f6f0e4, var(--paper));
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
}
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mist { position: fixed; inset: 0; pointer-events: none; opacity: .2; background-image: repeating-linear-gradient(105deg, transparent 0 55px, rgba(32,42,36,.025) 56px, transparent 57px 110px); }
.shell { position: relative; display: grid; grid-template-columns: 280px minmax(0, 1fr); height: 100vh; }
.conversations { padding: 28px 20px 22px; border-right: 1px solid var(--line); background: rgba(238,230,213,.72); backdrop-filter: blur(16px); display: grid; grid-template-rows: auto auto 1fr auto; min-height: 0; }
.identity { display: flex; align-items: center; gap: 13px; padding: 0 6px 25px; }
.seal { width: 42px; height: 42px; display: grid; place-items: center; color: var(--light); background: var(--red); font: 25px "Kaiti SC", "STKaiti", serif; box-shadow: inset 0 0 0 3px rgba(255,255,255,.18); }
.identity strong { display: block; font-size: 17px; letter-spacing: .14em; }
.identity small { display: block; margin-top: 3px; color: var(--soft); font-size: 9px; letter-spacing: .2em; }
.new-button { border: 1px solid var(--line); background: rgba(255,255,255,.36); padding: 13px 14px; text-align: left; transition: .2s; }
.new-button:hover { border-color: var(--red); background: rgba(165,65,48,.05); }
.new-button span { margin-right: 9px; color: var(--red); }
#conversation-list { overflow-y: auto; padding: 20px 0; display: grid; align-content: start; gap: 4px; }
.conversation-item { border: 0; border-left: 2px solid transparent; background: transparent; padding: 12px 13px; text-align: left; transition: .18s; }
.conversation-item:hover, .conversation-item.active { background: rgba(255,255,255,.42); border-left-color: var(--red); }
.conversation-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 600; }
.conversation-item small { display: block; margin-top: 5px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.privacy { border-top: 1px solid var(--line); padding: 17px 6px 0; color: var(--soft); font-size: 10px; line-height: 1.7; margin: 0; }
.dialogue { min-width: 0; display: grid; grid-template-rows: 78px minmax(0, 1fr) auto; height: 100vh; }
.dialogue header { display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(246,240,228,.55); backdrop-filter: blur(12px); }
.dialogue header > div { display: grid; grid-template-columns: 10px auto; align-items: center; column-gap: 10px; }
.dialogue header strong { font-size: 15px; letter-spacing: .15em; }
.dialogue header small { grid-column: 2; color: var(--soft); font-size: 9px; margin-top: 3px; letter-spacing: .08em; }
.presence { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(94,121,99,.12); grid-row: 1 / 3; }
.quiet-button, .mobile-menu { border: 1px solid var(--line); background: transparent; padding: 8px 13px; font-size: 11px; }
.mobile-menu { display: none; }
.messages { overflow-y: auto; padding: 48px clamp(24px, 8vw, 120px); scroll-behavior: smooth; }
.welcome { max-width: 720px; margin: 6vh auto 0; animation: arrive .7s ease both; }
.welcome > span { color: var(--red); letter-spacing: .3em; font-size: 10px; }
.welcome h1 { margin: 22px 0; font-size: clamp(38px, 5vw, 66px); line-height: 1.28; font-weight: 500; letter-spacing: .04em; }
.welcome p { max-width: 600px; color: var(--soft); line-height: 1.9; font-size: 14px; }
.suggestions { display: grid; gap: 8px; margin-top: 34px; max-width: 580px; }
.suggestions button { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.34); padding: 13px 16px; font-size: 12px; transition: .2s; }
.suggestions button:hover { transform: translateX(5px); border-color: rgba(165,65,48,.45); }
.message { max-width: 720px; margin: 0 auto 30px; animation: arrive .3s ease both; }
.message.user { display: flex; justify-content: flex-end; }
.message.user p { max-width: 80%; padding: 13px 17px; background: var(--ink); color: var(--light); }
.message.assistant { border-left: 2px solid var(--red); padding-left: 22px; }
.message span { display: block; color: var(--red); font-size: 9px; letter-spacing: .16em; margin-bottom: 9px; }
.message p { margin: 0; white-space: pre-wrap; line-height: 1.95; font-size: 15px; }
.message.pending p { color: var(--soft); }
.composer { margin: 0 clamp(20px, 7vw, 105px) 24px; padding: 12px 12px 8px 18px; display: grid; grid-template-columns: 1fr 46px; gap: 8px 12px; background: rgba(248,243,232,.92); border: 1px solid rgba(255,255,255,.82); box-shadow: 0 18px 55px rgba(54,44,31,.12); }
.composer textarea { border: 0; outline: none; resize: none; background: transparent; min-height: 46px; max-height: 160px; padding: 11px 0; line-height: 1.65; }
.composer > button { width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--red); color: white; font-size: 22px; }
.composer > button:disabled { opacity: .45; cursor: wait; }
.composer small { grid-column: 1 / 3; color: var(--soft); font-size: 9px; }
@keyframes arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .conversations { position: fixed; inset: 0 20% 0 0; z-index: 10; transform: translateX(-105%); transition: .25s; box-shadow: 20px 0 60px rgba(30,30,20,.18); }
  .conversations.open { transform: none; }
  .dialogue header { height: 68px; padding: 0 16px; }
  .mobile-menu { display: block; }
  .quiet-button { font-size: 0; }
  .quiet-button::after { content: "＋"; font-size: 20px; }
  .messages { padding: 30px 19px; }
  .welcome { margin-top: 3vh; }
  .welcome h1 { font-size: 39px; }
  .composer { margin: 0 12px 12px; }
  .message.user p { max-width: 90%; }
}

/* Voice additions */
.composer { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; min-width: 0; }
.composer .voice-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255,255,255,.4); display: grid; place-items: center;
}
.composer .voice-btn.listening {
  background: var(--red); color: var(--light); animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(165,65,48,.35); }
  70% { box-shadow: 0 0 0 10px rgba(165,65,48,0); }
  100% { box-shadow: 0 0 0 0 rgba(165,65,48,0); }
}
.composer small { width: 100%; }
#voice-status { margin-left: 8px; color: var(--soft); }

.message.assistant { position: relative; }
.play-btn {
  position: absolute; right: 12px; bottom: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.5);
  font-size: 11px; display: grid; place-items: center;
}
.play-btn:hover { background: rgba(94,121,99,.12); border-color: var(--green); }


/* 登录界面 */
.auth-screen { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: var(--paper, #eee6d5); }
.auth-card { width: min(360px, 88vw); display: flex; flex-direction: column; gap: 12px; padding: 36px 30px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(30,30,20,.12); text-align: center; }
.auth-card .seal { font-size: 28px; }
.auth-card h1 { font-size: 26px; margin: 0; }
.auth-card p { font-size: 12px; color: var(--soft); margin: 0 0 8px; }
.auth-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; }
.auth-submit { padding: 11px; border: 0; border-radius: 8px; background: var(--red); color: #fff; font-size: 15px; cursor: pointer; }
.auth-submit:disabled { opacity: .5; }
.auth-switch { border: 0; background: none; color: var(--soft); font-size: 12px; cursor: pointer; text-decoration: underline; }
.auth-error { color: var(--red); font-size: 12px; min-height: 16px; margin: 0; }

/* 账号栏与移动端面板 */
.account-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--soft); }
.panel-close { display: none; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--soft); cursor: pointer; margin-left: auto; }
.panel-backdrop { position: fixed; inset: 0; z-index: 9; background: rgba(30,30,20,.25); }
.identity { display: flex; align-items: center; gap: 8px; }
@media (max-width: 760px) {
  .panel-close { display: block; }
}
.auth-screen[hidden], .shell[hidden] { display: none !important; }
.voice-tap { border: 1px solid var(--red); background: #fff; color: var(--red); border-radius: 999px; padding: 4px 12px; font-size: 11px; cursor: pointer; }
