:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #eee6f4;
  background: #17131e;
  font-synthesis: none;
  --page-gap: clamp(12px, 1.6vw, 24px);
  --panel-radius: clamp(18px, 2vw, 28px);
  --visual-height: 100vh;
}
@supports (height: 100dvh) { :root { --visual-height: 100dvh; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 12% 12%, #382941, #1c1724 55%, #13121b); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; min-height: 44px; min-width: 44px; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, a:focus-visible { outline: 2px solid #d8b9e4; outline-offset: 4px; }
a { color: inherit; text-decoration: none; }
button { transition: background-color .2s, color .2s, border-color .2s, box-shadow .2s; }
.app { width: 100%; max-width: 1560px; min-height: 100vh; min-height: var(--visual-height); margin-inline: auto; display: flex; flex-direction: column; gap: var(--page-gap); padding: max(18px, env(safe-area-inset-top)) max(clamp(16px, 3vw, 44px), env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(clamp(16px, 3vw, 44px), env(safe-area-inset-left)); }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; min-height: 42px; }
.wordmark { font-size: clamp(20px, 1.7vw, 25px); font-weight: 600; letter-spacing: 3px; white-space: nowrap; }
.wordmark span { font-weight: 300; color: #cbb5d5; }
.wordmark small { display: block; color: #9a85a6; font-size: 8px; letter-spacing: 3px; margin-top: 5px; }
.local-pill { font-size: 11px; color: #b6bdaf; white-space: nowrap; }
.local-pill i { display: inline-block; width: 5px; height: 5px; background: #b1c7a7; border-radius: 50%; margin-right: 7px; box-shadow: 0 0 10px #b1c7a733; }
.avatar-choice { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; padding: 8px 14px; border: 1px solid #ffffff10; border-radius: 16px; background: #241d2c80; }
.avatar-choice > span { font-size: 12px; color: #c5afd2; }
.avatar-choice > div { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.avatar-choice button { font-size: 13px; border: 1px solid transparent; border-radius: 11px; background: #ffffff04; color: #b39cc3; padding: 9px 20px; }
.avatar-choice button.selected { color: #302039; background: #c9abd0; border-color: #ddc4e3; box-shadow: 0 3px 14px #b690c219; }
.avatar-choice .motion-preview { border-color: #b18cbe2b; background: transparent; font-size: 12px; padding-inline: 14px; }
.avatar-choice > small { font-size: 11px; color: #a18bae; margin-left: auto; line-height: 1.7; }
main { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr); gap: var(--page-gap); flex: 1; min-height: 520px; }
.portrait, .conversation { min-width: 0; border-radius: var(--panel-radius); }
.portrait { position: relative; overflow: hidden; background: #f9f8fe; border: 1px solid #d8c9df36; isolation: isolate; min-height: 520px; box-shadow: 0 16px 50px #0a061d26; }
.portrait::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 75px #ffffff14; z-index: 1; }
#avatar { width: 100%; height: 100%; position: absolute; inset: 0; display: block; transition: opacity .32s ease; }
.portrait.is-switching #avatar { opacity: .32; }
.portrait-caption { position: absolute; left: clamp(20px, 2.3vw, 36px); top: clamp(24px, 2.5vw, 38px); z-index: 2; pointer-events: none; color: #68517d; }
.portrait-caption > span { font-size: 11px; color: #8c799a; letter-spacing: 1px; }
.portrait-caption h1 { font-family: "Songti SC", "Noto Serif CJK SC", STSong, Georgia, serif; font-size: clamp(26px, 2.4vw, 38px); line-height: 1.65; font-weight: 400; letter-spacing: 2px; text-shadow: 0 2px 16px #ffffffad; margin: 14px 0 0; }
.portrait-footer { position: absolute; left: clamp(20px, 2.3vw, 36px); bottom: 28px; z-index: 2; color: #604b73; text-shadow: 0 1px 12px #ffffffbb; }
.portrait-footer strong { display: block; font-size: 15px; font-weight: 500; letter-spacing: 2px; }
.portrait-footer small { display: block; font-size: 11px; letter-spacing: 1px; color: #8b7898; margin-top: 8px; }
.avatar-loading { position: absolute; inset: 0; background: #f9f8fe; display: grid; place-items: center; font-size: 13px; color: #8a719a; z-index: 3; }
.conversation { border: 1px solid #ffffff10; background: linear-gradient(155deg, #2c22313d, #17131e65); padding: clamp(22px, 3vw, 42px); display: flex; flex-direction: column; min-height: 0; box-shadow: inset 0 1px 0 #ffffff03; }
.invite-panel { max-width: 400px; width: 100%; margin: auto; padding-block: 8px; }
.eyebrow { font-size: 10px; letter-spacing: 2.2px; color: #b09bbb; }
.invite-panel h2 { font-family: "Songti SC", STSong, Georgia, serif; font-size: clamp(27px, 2.5vw, 34px); font-weight: 400; letter-spacing: 2px; line-height: 1.45; margin: 14px 0 10px; }
.invite-panel > p { font-size: 14px; line-height: 1.9; color: #bfaacb; margin: 0 0 14px; }
.auth-tabs { display: flex; border-bottom: 1px solid #b990bd24; gap: 28px; margin-bottom: 18px; }
.auth-tabs button { border: 0; border-bottom: 2px solid transparent; background: none; color: #a18aac; padding: 8px 0; font-size: 14px; }
.auth-tabs button.selected { border-color: #c6a5c5; color: #e1c7e6; }
#inviteForm, #passwordForm { display: flex; flex-direction: column; gap: 10px; }
#inviteForm label, #passwordForm label { font-size: 12px; letter-spacing: .5px; color: #bca6c8; }
#inviteForm input, dialog input:not([type=checkbox]) { width: 100%; min-width: 0; min-height: 48px; padding: 12px 15px; background: #100d166b; border: 1px solid #bc96c335; border-radius: 12px; color: #f0e5f4; outline: none; font-size: 16px; }
#inviteRow { display: flex; flex-direction: column; gap: 10px; }
input:focus { border-color: #d1aad8 !important; box-shadow: 0 0 0 3px #c49ad00e; }
input::placeholder { color: #8e789d; font-size: 13px; letter-spacing: .2px; }
.primary { border: 1px solid #dbc4df66; border-radius: 12px; background: linear-gradient(110deg, #d2b4d0, #bca1d0); color: #302039; padding: 13px 18px; font-size: 14px; font-weight: 500; }
.primary span { float: right; }
#inviteError, #passwordResult { font-size: 12px; color: #ddaebc; line-height: 1.7; overflow-wrap: anywhere; }
#inviteError:empty, #passwordResult:empty { display: none; }
.invitation-note { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; color: #a88db8; }
.invitation-note > span { font-size: 20px; }
.invitation-note p { margin: 0; font-size: 11px; line-height: 1.85; color: #a18aad; }
.chat-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.call-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-shrink: 0; }
.call-heading h2 { font-size: clamp(17px, 1.6vw, 22px); font-weight: 500; letter-spacing: .6px; margin: 9px 0 12px; line-height: 1.5; }
#timer { color: #a18bac; font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 22px; flex: none; }
#messages { flex: 1; min-height: 100px; overflow: auto; padding: 18px 1px; scrollbar-width: thin; scrollbar-color: #71577f transparent; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.welcome-message { text-align: center; padding: clamp(24px, 6vh, 70px) 12px; color: #c5afce; }
.welcome-message > span { font-size: 24px; }
.welcome-message h3 { font-family: "Songti SC", STSong, Georgia, serif; font-size: clamp(22px, 2vw, 29px); font-weight: 400; letter-spacing: 3px; color: #e7d8ed; margin: 18px 0 12px; }
.welcome-message p { font-size: 13px; color: #b49bc0; }
.bubble { max-width: 94%; padding: 12px 15px; border-radius: 15px; margin-bottom: 15px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.85; }
.bubble small { display: block; font-size: 11px; color: #a58bb3; margin-bottom: 5px; }
.bubble.user { background: #9c7ca52c; margin-left: auto; border-bottom-right-radius: 4px; color: #e0ceeb; }
.bubble.assistant { background: #ffffff04; border: 1px solid #ffffff0d; border-bottom-left-radius: 4px; }
.activity { display: flex; gap: 13px; align-items: center; min-height: 58px; padding: 10px 0 14px; flex-shrink: 0; }
.activity span { font-size: 13px; color: #d3bcdf; }
.activity small { display: block; margin-top: 5px; font-size: 11px; color: #a58db2; line-height: 1.6; }
.wave { display: flex; align-items: center; gap: 3px; min-width: 49px; height: 28px; }
.wave i { width: 3px; height: 4px; border-radius: 3px; background: #c4a0d2; transition: height .12s; }
#textForm { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 14px; background: #100c176b; border: 1px solid #bc96c32b; border-radius: 13px; flex-shrink: 0; }
#textInput { background: none; border: 0; outline: none; color: #eee2f5; font-size: 16px; min-height: 44px; flex: 1; min-width: 0; }
#textInput:focus { box-shadow: none; }
#textForm button { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 0; background: #b08bbb40; color: #efdff3; font-size: 21px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; flex-shrink: 0; }
.controls button { font-size: 13px; padding: 10px 14px; border-radius: 11px; }
.controls .primary { flex: 1; }
.secondary { border: 1px solid #ffffff19; background: #ffffff05; color: #ceb5dc; }
.end { border: 1px solid #bf7b8b40; background: #ad65791b; color: #e0b1be; }
.privacy-note { font-size: 10px; text-align: center; color: #9d87aa; margin: 12px 0 0; flex-shrink: 0; }
footer { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; font-size: 11px; letter-spacing: .5px; color: #a38caf; }
footer > div { display: flex; gap: 6px 14px; flex-wrap: wrap; justify-content: flex-end; }
footer button { border: 0; padding: 7px 2px; background: none; color: #b69ac5; font-size: 12px; }
.occupancy-banner { flex: none; border: 1px solid #ba94c339; background: #9874ad14; border-radius: 13px; padding: 12px 18px; color: #dcc4e6; font-size: 13px; line-height: 1.8; text-align: center; }
.waiting-panel { max-width: 390px; width: 100%; margin: auto; text-align: center; display: flex; align-items: center; flex-direction: column; padding-block: 18px; }
.waiting-orbit { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #b28eb836; background: radial-gradient(circle, #bb8bd414, transparent 75%); color: #dab6e0; font-size: 31px; margin: 24px 0 8px; }
.waiting-panel h2 { font-family: "Songti SC", STSong, Georgia, serif; font-weight: 400; letter-spacing: 1px; line-height: 1.6; font-size: clamp(23px, 2vw, 28px); margin: 16px 0 10px; }
.waiting-panel p { font-size: 14px; color: #d5bcdf; line-height: 1.9; max-width: 330px; margin: 6px 0 12px; }
.waiting-panel small { font-size: 12px; color: #b29bbf; line-height: 1.8; }
.waiting-panel button { margin-top: 22px; border-radius: 11px; padding: 12px 22px; font-size: 13px; min-width: 160px; }
.waiting-panel .primary + .secondary { margin-top: 10px; }
dialog { position: fixed; inset: auto; top: calc(var(--visual-top, 0px) + var(--visual-height) / 2); left: 50%; transform: translate(-50%, -50%); margin: 0; width: min(480px, calc(100% - 32px)); max-height: calc(var(--visual-height) - 32px); overflow: auto; overscroll-behavior: contain; border: 1px solid #bc97c442; border-radius: 22px; background: #241d2e; color: #eee4f3; padding: 24px; }
dialog::backdrop { background: #0d0915c4; backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { font-size: 22px; font-weight: 500; margin: 8px 0; }
.dialog-heading button { width: 44px; border: 0; background: none; color: #d3b6df; font-size: 27px; }
dialog p { font-size: 13px; color: #bfa7ce; line-height: 1.8; }
dialog h3 { font-size: 16px; font-weight: 500; margin: 20px 0 12px; }
#adminPanel { border-top: 1px solid #ffffff15; margin-top: 14px; }
.registration-control { display: flex; align-items: center; gap: 9px; font-size: 14px; min-height: 44px; }
.registration-control input { width: 20px; height: 20px; accent-color: #b995c8; }
.admin-user { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #ffffff10; padding: 10px 0; font-size: 14px; overflow-wrap: anywhere; }
.admin-user button { padding: 8px 14px; border-radius: 10px; flex: none; }
.hidden { display: none !important; }
#toast { position: fixed; bottom: calc(max(22px, env(safe-area-inset-bottom)) + max(0px, 100vh - var(--visual-height) - var(--visual-top, 0px))); left: 50%; transform: translate(-50%, 14px); opacity: 0; pointer-events: none; z-index: 10; background: #35253ff5; border: 1px solid #ac84b540; padding: 13px 18px; width: max-content; max-width: calc(100vw - 32px); border-radius: 13px; font-size: 13px; color: #eadbef; transition: opacity .2s, transform .2s; line-height: 1.8; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (hover: hover) {
  .secondary:hover, .avatar-choice button:not(.selected):hover { background: #c5a1d012; border-color: #b58dc547; }
  .primary:hover { box-shadow: 0 6px 24px #bd98c526; }
}
/* Tablet portrait stays side by side rather than becoming a stretched phone. */
@media (min-width: 720px) and (max-width: 1099px) {
  .app { padding-inline: 22px; gap: 14px; }
  main { grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); gap: 16px; }
  .conversation { padding: 22px; }
  .portrait-caption { left: 20px; top: 24px; }
  .portrait-caption h1 { font-size: 25px; }
  .portrait-caption > span { font-size: 10px; }
  .portrait-footer { left: 20px; bottom: 22px; }
  .avatar-choice > small { flex-basis: 100%; margin-left: 0; }
  .avatar-choice { gap: 4px 14px; }
  .invitation-note p { font-size: 10px; }
}
/* While chatting, the transcript scrolls and input/actions stay inside the visible viewport. */
body.has-session { height: var(--visual-height); min-height: 0; overflow: hidden; }
body.has-session .app { height: var(--visual-height); min-height: 0; }
body.keyboard-open.has-session .app { position: fixed; left: 0; right: 0; top: var(--visual-top, 0px); }
body.has-session main { min-height: 0; }
body.has-session .portrait { min-height: 0; }
body.has-session .conversation { overflow: hidden; }
body.has-session #messages { min-height: 0; }
body.has-session .waiting-panel { overflow: auto; }
@media (max-width: 719px) {
  .app { gap: 12px; padding-inline: max(14px, env(safe-area-inset-left)); padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  header { min-height: 36px; }
  .wordmark { font-size: 20px; letter-spacing: 2px; }
  .wordmark small { font-size: 7px; letter-spacing: 2.6px; }
  .local-pill { font-size: 10px; }
  .avatar-choice { padding: 6px; gap: 4px; border-radius: 14px; }
  .avatar-choice > span, .avatar-choice > small { display: none; }
  .avatar-choice > div { flex: 1; display: grid; grid-template-columns: .9fr .9fr 1.2fr; gap: 5px; }
  .avatar-choice button { padding: 8px 10px; font-size: 13px; }
  .avatar-choice .motion-preview { font-size: 12px; padding-inline: 8px; }
  main { grid-template-columns: minmax(0, 1fr); flex: none; min-height: 0; gap: 12px; }
  .portrait { min-height: 0; height: clamp(180px, 25svh, 245px); }
  .portrait-caption { left: 18px; top: 19px; max-width: 46%; }
  .portrait-caption > span { font-size: 9px; letter-spacing: .2px; }
  .portrait-caption h1 { font-size: clamp(21px, 5.7vw, 27px); line-height: 1.6; letter-spacing: 1px; margin-top: 9px; }
  .portrait-footer { left: 18px; bottom: 17px; }
  .portrait-footer strong { font-size: 12px; }
  .portrait-footer small { font-size: 9px; letter-spacing: .2px; margin-top: 5px; }
  .conversation { padding: 22px 19px; }
  .invite-panel { padding: 0; }
  .invite-panel h2 { font-size: 27px; margin-top: 10px; }
  .invite-panel > p { font-size: 13px; margin-bottom: 9px; }
  .auth-tabs { margin-bottom: 14px; gap: 25px; }
  #inviteForm { gap: 9px; }
  .invitation-note { margin-top: 14px; gap: 9px; }
  .invitation-note p { font-size: 10px; }
  footer { font-size: 10px; align-items: center; }
  footer > div { gap: 4px 8px; }
  footer button { font-size: 11px; min-height: 44px; }
  body.has-session .app { gap: 8px; }
  body.has-session main { flex: 1; display: flex; flex-direction: column; gap: 8px; }
  body.has-session .portrait { flex: none; height: clamp(130px, 20svh, 185px); }
  body.has-session .portrait-caption { top: 14px; }
  body.has-session .portrait-caption > span { display: none; }
  body.has-session .portrait-caption h1 { font-size: 20px; margin: 0; }
  body.has-session .portrait-footer { bottom: 12px; }
  body.has-session .portrait-footer small { display: none; }
  body.has-session .conversation { flex: 1; padding: 14px; }
  body.has-session .call-heading h2 { font-size: 17px; margin: 3px 0 6px; }
  body.has-session .call-heading .eyebrow { font-size: 8px; }
  body.has-session #timer { padding-top: 10px; font-size: 11px; }
  body.has-session #messages { padding-block: 12px; }
  body.has-session .bubble { padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
  body.has-session .activity { min-height: 40px; padding: 6px 0 9px; }
  body.has-session .activity span { font-size: 12px; }
  body.has-session .activity small { font-size: 10px; margin-top: 3px; }
  body.has-session .controls { margin-top: 8px; gap: 6px; }
  body.has-session .controls button { padding-inline: 10px; font-size: 12px; }
  body.has-session .privacy-note { display: none; }
  body.has-session footer > span { display: none; }
  body.has-session footer > div { width: 100%; gap: 0; justify-content: space-between; }
  body.has-session footer button { min-height: 44px; padding-inline: 3px; }
  .waiting-panel { padding-block: 10px; }
  .waiting-orbit { width: 52px; height: 52px; font-size: 24px; margin: 12px 0 4px; }
  .waiting-panel h2 { font-size: 22px; margin-top: 10px; }
  .waiting-panel p { font-size: 13px; }
  .waiting-panel small { font-size: 11px; }
  dialog { padding: 19px; }
  #toast { font-size: 12px; }
  body.keyboard-open.has-session header, body.keyboard-open.has-session .avatar-choice, body.keyboard-open.has-session .portrait, body.keyboard-open.has-session footer { display: none; }
  body.keyboard-open.has-session .app { padding-block: 6px; }
  body.keyboard-open:not(.has-session) .portrait { display: none; }
}
/* Phone landscape and short windows prioritize the conversation over decorative portrait space. */
@media (max-width: 719px) and (max-height: 680px) {
  body.has-session header { display: none; }
  body.has-session .app { gap: 6px; }
  body.has-session .portrait { height: 96px; }
  body.has-session .portrait-caption { top: 18px; }
  body.has-session .portrait-caption h1 { font-size: 17px; line-height: 1.4; }
  body.has-session .portrait-footer { display: none; }
  body.has-session .activity small { display: none; }
}
@media (min-width: 720px) and (max-height: 700px) {
  body.has-session .app { padding-block: 10px; gap: 10px; }
  body.has-session header { min-height: 32px; }
  body.has-session .wordmark small, body.has-session .avatar-choice > span, body.has-session .avatar-choice > small { display: none; }
  body.has-session .avatar-choice { padding-block: 4px; }
  body.has-session .conversation { padding: 16px; }
  body.has-session .activity { min-height: 44px; }
}
@media (max-height: 560px) {
  body.has-session .app { padding-block: 8px; gap: 6px; }
  body.has-session .wordmark small, body.has-session .avatar-choice > span, body.has-session .avatar-choice > small { display: none; }
  body.has-session .avatar-choice { padding-block: 2px; }
  body.has-session .conversation { padding: 12px 16px; }
  body.has-session .call-heading .eyebrow, body.has-session .activity small, body.has-session .privacy-note { display: none; }
  body.has-session .call-heading h2 { margin: 0 0 6px; font-size: 17px; }
  body.has-session .activity { min-height: 30px; padding: 4px 0; }
  body.has-session #timer { padding-top: 4px; }
  body.has-session footer { display: none; }
  body.has-session #messages { min-height: 0; padding-block: 8px; }
  body.has-session .controls { margin-top: 6px; }
}
@media (max-height: 500px) { body.has-session header { display: none; } }
@media (max-width: 719px) and (max-height: 560px) { body.has-session .portrait { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
