/* Girlfriend / 我的女友 session layout. Loaded only on the workbench. */

.studio.studio-gf { align-items: stretch; }
.studio-gf .composer {
  align-content: start;
  min-height: 0;
}
.studio-gf .products {
  align-self: start;
  align-items: center;
}
body.has-gf-chat #products { display: none; }
body.has-gf-chat #modes { display: none !important; }
body.has-gf-chat .studio { padding-bottom: 0; }
.studio-gf #panel-girlfriend { align-content: start; }
.studio-gf .stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 140px);
  padding: 0;
  overflow: hidden;
  align-content: stretch;
}

.chat-dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: 100%;
}
.chat-summon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 56px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 20px;
  background: var(--surface);
  color: var(--text);
}
.chat-summon[hidden] { display: none; }
.chat-summon-title {
  margin: 0;
  font-size: var(--fs-lead);
  font-weight: 700;
}
.chat-summon-bar {
  width: min(240px, 72%);
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.chat-summon-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--c-chat);
}
.chat-summon-stage {
  margin: 0;
  font-size: var(--fs-note);
  color: var(--muted);
}
.chat-dialog.is-summoning .chat-head-new,
.chat-dialog.is-summoning .chat-composer {
  pointer-events: none;
  opacity: 0.45;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.chat-head-art {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--field);
  flex: 0 0 auto;
}
.chat-head-meta { min-width: 0; flex: 1; }
.chat-head-name { font-weight: 700; font-size: var(--fs-lead); }
.chat-head-int { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--muted); }
.chat-head-back,
.chat-head-new { display: inline-flex; flex: 0 0 auto; }

.gf-picker {
  display: grid;
  gap: 8px;
  min-height: 0;
}
.gf-picker-title {
  margin: 0;
  font-size: var(--fs-note);
  font-weight: 600;
  color: var(--muted);
}
.gf-picker-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
.gf-pick {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  text-align: left;
}
.gf-pick.is-current { border-color: var(--c-chat); }
.gf-pick img {
  grid-row: 1 / span 2;
  display: block;
  width: 48px;
  height: 64px;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 8px;
  background: var(--field);
}
.gf-pick strong { font-size: var(--fs-note); }
.gf-pick span {
  font-size: var(--fs-cap);
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gf-picker-hint { display: none; }
@media (min-width: 960px) {
  .gf-picker-stage { display: none; }
  .gf-picker-hint { display: block; }
}
.chat-head-back { order: -1; }

.chat-thread {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 12px 12px 8px;
  scrollbar-gutter: stable;
}

.chat-thread > .chat-msg:first-child {
  margin-top: auto;
}
.chat-media {
  margin-top: 8px;
}
.chat-media img,
.chat-media video {
  display: block;
  width: auto;
  height: auto;
  max-width: min(168px, 56vw);
  max-height: min(240px, 42vh);
  border-radius: 10px;
  object-fit: contain;
}
.chat-msg.pending { opacity: 0.75; }
.chat-dock {
  position: relative;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-msg {
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: var(--fs-body);
  line-height: 1.55;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--field);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--feature);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
}
.chat-msg.streaming::after {
  content: "▍";
  margin-left: 1px;
  animation: chat-caret 1s step-end infinite;
}
@keyframes chat-caret {
  50% { opacity: 0; }
}
.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.chat-composer textarea {
  min-height: 48px;
  max-height: 132px;
  resize: none;
  overflow-y: auto;
  scrollbar-width: none;
}
.chat-composer textarea::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--r);
  background: var(--feature);
  color: var(--accent-ink);
  font-weight: 650;
}
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send.locked { background: var(--surface-2); color: var(--text); opacity: 1; cursor: pointer; }
.chat-send .go-cost {
  font-size: var(--fs-sm);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(11, 13, 18, 0.22);
}
.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.chat-time { font-size: var(--fs-cap); color: var(--faint); }
.chat-resend,
.chat-stop {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-cap);
  padding: 0;
  cursor: pointer;
}
.chat-empty {
  color: var(--faint);
  font-size: var(--fs-note);
  padding: 24px 8px;
  text-align: center;
}

@media (max-width: 959px) {
  .studio.studio-gf {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 8px;
    padding: 8px 10px calc(16px + var(--bottom-nav-h));
    align-items: stretch;
  }
  .studio-gf .composer {
    flex: 0 0 auto;
    gap: 8px;
  }
  .studio-gf .products {
    position: sticky;
    top: calc(var(--topbar-h) + var(--announce-h));
    z-index: 5;
  }
  .studio-gf #panel-girlfriend { display: none !important; }
  .studio-gf .stage {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0 !important;
    max-height: none;
    height: auto;
    padding: 0;
    overflow: hidden;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .chat-send { min-width: 72px; padding: 10px 12px; }
  .chat-dialog {
    flex: 1 1 auto;
    max-height: none;
    height: auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
  }
  html:has(body.has-gf-chat),
  body.has-gf-chat {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.has-gf-chat {
    position: fixed;
    inset: 0;
    width: 100%;
  }
  body.has-gf-chat .composer { display: none !important; }
  body.has-gf-chat .studio.studio-gf {
    max-height: 100%;
    overflow: hidden;
    padding-bottom: 0;
  }
  .chat-head {
    flex-shrink: 0;
    min-width: 0;
    gap: 6px;
    padding: 8px;
    background: var(--surface);
  }
  .chat-head .chip {
    padding: 8px 10px;
    font-size: var(--fs-sm);
  }
  .chat-head-meta { display: none; }
  .chat-dock {
    flex: none;
    position: relative;
    z-index: 4;
  }
  .chat-head-art { width: 32px; height: 32px; }
  .chat-head-name { display: none; }
  .chat-composer textarea { font-size: var(--fs-lead); }
}

@media (hover: hover) and (pointer: fine) {
  .gf-pick:hover { background: var(--surface-2); }
  .chat-send:hover:not(:disabled) { filter: brightness(1.12); }
  .chat-resend:hover,
  .chat-stop:hover { color: var(--text); }
}

.gf-pick:active:not(:disabled),
.chat-send:active:not(:disabled),
.chat-resend:active:not(:disabled),
.chat-stop:active:not(:disabled) {
  filter: brightness(0.82);
}
