/* Portrait and text retain separate layers so scrolling never moves the person. */
.chat-shell {
  isolation: isolate;
  color: #fff;
  background: #263039 url("companion-assets/alan-scene.jpg") 95% 130% / auto 149% no-repeat;
}
.chat-shell::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #102132a6, #10213210 13%, transparent 33%, #20283722 48%, #18243095 71%, #182430 86%);
}
.chat-shell [hidden] { display: none !important; }
.chat-head {
  background: transparent;
  border: 0;
  padding: 14px 15px 6px;
  gap: 9px;
  min-height: 62px;
}
.chat-head .back, .chat-head .call-button {
  border: 1px solid #ffffff52;
  background: #182a39b8;
  color: white;
}
.chat-head .back {width: 37px; height: 37px;}
.chat-head img {border: 1.5px solid #ffffffdb; object-position: center 44%;}
.chat-person h1 {font-size: 21px; line-height: 1.15; text-shadow: 0 1px 5px #15243580;}
.chat-person > span {display: block; color: #f1f6fb; margin-top: 2px; font-size: 11px; text-shadow: 0 1px 5px #152435;}
.chat-person b {color: #fbedf5; font-weight: 600;}
.chat-head .call-button {display: flex; align-items: center; gap: 5px; width: auto; height: 36px; border-radius: 20px; padding: 0 11px; font-weight: 650; font-size: 13px;}
.chat-head .call-button [data-icon] {width: 15px; height: 15px; color: #abecff;}
#source {padding-left: 15px; align-self: flex-start; max-width: 96%; flex: none;}
#source:empty {display: none;}
.source-strip {display: inline-flex; min-height: 26px; padding: 1px 2px 1px 9px; gap: 7px; color: #f7fbff; background: #182630b8; border: 1px solid #ffffff44; border-radius: 18px;}
.source-strip a {color: #c3edff; font-size: 11px; padding: 4px 7px;}
.source-strip span {font-size: 10px;}
.portrait-window {flex: 0 1 31%; min-height: 0; pointer-events: none;}
.messages {
  display: flex;
  flex-direction: column;
  background: transparent;
  padding: 20px 15px 6px;
  scrollbar-width: none;
  overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(transparent,#000 22px);
  mask-image: linear-gradient(transparent,#000 22px);
}
.messages:focus-visible {outline: 1px solid #b8efff; outline-offset: -2px;}

.messages .line {flex: none; margin: 0 0 11px;}
.messages .line:last-child {margin-bottom: 3px;}
.messages > .line:first-child {margin-top: auto;}
.reply-card, .line.me .bubble {
  border: 1px solid #ffffff40;
  border-radius: 17px 17px 17px 4px;
  color: white;
  background: #17232dc4;
  max-width: 88%;
  padding: 11px 13px 10px;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 8px #17232d20;
}
.reply-header {display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;}
.reply-header b {color: #ffb5d9; font-size: 13px; letter-spacing: .02em;}
.read-voice {border: 1px solid #ffffff4a; background: #ffffff12; color: white; width: 37px; height: 28px; display: grid; place-items: center; border-radius: 20px;}
.read-voice svg {width: 18px; height: 14px;}
.read-voice[aria-pressed=true] {color: #b3efff; background: #084e6e;}
.voice-error {font-size: 11px; color: #ffd2e7;}
.reply-card .stage-action, .reply-card .inner-thought {font-size: 13px; line-height: 1.6; margin-bottom: 2px;}
.stage-action {color: #ffd2e6;}
.inner-thought {color: #cce5f8;}
.reply-text {font-size: 15px; line-height: 1.65; white-space: pre-wrap; margin-top: 4px;}
.reply-info, .message-info {display: block; margin-top: 6px; font-size: 10px; line-height: 1.3;}
.reply-info {color: #c9d4df;}
.line.me .bubble {background: #e0f4f9; color: #203d48; border-color: #ffffffb0; border-radius: 16px 16px 4px 16px; font-size: 14px; padding: 10px 13px;}
.message-info {color: #506975;}
.line.call-line, .line.media {padding-left: 0;}
.call-record,.media-card {color: var(--ink);}
.compose-area {position: relative; padding: 5px 13px max(10px,env(safe-area-inset-bottom)); background: transparent; border: 0;}
.writing-tools {display: flex; gap: 7px; margin: 1px 0 8px;}
.writing-tools button, .compose-area .prompts button {color: #f3f7fb; background: #172733d9; border: 1px solid #ffffff45; border-radius: 20px; padding: 6px 9px; font-size: 11px;}
.composer {border-radius: 27px; background: #142435ee; border: 1px solid #cbe8fa65; padding: 6px; gap: 6px;}
.composer > img {width: 30px; height: 30px; border: 1px solid #ffffff68; border-radius: 50%; object-fit: cover;}
.composer input {background: #35434f; border: 0; border-radius: 20px; color: white; height: 36px; padding: 0 12px;}
.composer input::placeholder {color: #d4dfe9; opacity: 1;}
.composer .send {color: white; background: #007ca6; width: 36px; height: 36px;}
#chat-tools {position: absolute; z-index: 3; bottom: calc(100% - 2px); left: 13px; right: 13px; border: 1px solid #71818b; border-radius: 18px; color: white; background: #172836fa; box-shadow: 0 7px 24px #101a25a8; padding: 13px;}
#chat-tools .tool-row {display: flex; gap: 9px; margin-bottom: 10px;}
.tool-row a,.tool-row button {display: inline-flex; align-items: center; gap: 6px; color: #d4f2fc; font: inherit; font-size: 13px; background: none; border: 0; padding: 5px;}
.tool-row [data-icon] {width: 17px; height: 17px;}
#chat-tools small {color: #cad6e1; font-size: 10px;}
@media (max-height:650px) {
  .portrait-window {flex-basis: 23%;}
  .chat-head {padding-top: 8px; min-height: 55px;}
}
@media (max-height:480px) {
  .portrait-window {flex-basis: 0;}
  .writing-tools {display: none;}
  .compose-area {padding-bottom: 4px;}
}
