/* 赛博女友 · 苹果风格磨砂玻璃界面 */

:root {
  --glass: rgba(255, 255, 255, 0.15);
  --glass-strong: rgba(255, 255, 255, 0.22);
  --glass-solid: rgba(255, 255, 255, 0.3);
  --stroke: rgba(255, 255, 255, 0.34);
  --stroke-soft: rgba(255, 255, 255, 0.18);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.75);
  --faint: rgba(255, 255, 255, 0.55);
  --accent: #ff7fa2;
  --accent-soft: #ffb3c7;
  --accent-deep: #e8608a;
  --shadow: 0 12px 40px rgba(24, 6, 16, 0.28);
  --shadow-lg: 0 24px 70px rgba(24, 6, 16, 0.38);
  --r-md: 18px;
  --r-lg: 24px;
  --r-full: 999px;
  --blur: blur(30px) saturate(180%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* 组件自带 display 会盖掉 [hidden] 的 UA 样式，这里统一兜底 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #14100f;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font-family: inherit; }

.app { position: fixed; inset: 0; }

/* ---------- 画面 ---------- */
.stage { position: absolute; inset: 0; background: #14100f; }

.video { position: absolute; inset: 0; }
#video video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
}
.video.hidden { visibility: hidden; }

.stage-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    radial-gradient(1100px 620px at 50% 42%, rgba(255, 176, 194, 0.2), transparent 68%),
    linear-gradient(160deg, #2b2024 0%, #1a1315 48%, #2c1f24 100%);
  transition: opacity 0.7s ease;
  overflow: hidden;
}
.stage-fallback.hidden { opacity: 0; pointer-events: none; }

/* 待机画面：高清人物大图铺满整屏 */
.fallback-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 26%;
  display: block;
  transition: opacity 0.5s ease;
}
.fallback-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(12, 7, 10, 0.88) 0%, rgba(12, 7, 10, 0.34) 22%, rgba(12, 7, 10, 0) 50%),
    radial-gradient(130% 92% at 50% 30%, rgba(12, 7, 10, 0) 40%, rgba(12, 7, 10, 0.52) 100%);
}
.fallback-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 23%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  text-align: center;
}
.fallback-glow {
  position: absolute;
  top: 50%; left: 50%;
  margin: -160px 0 0 -160px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 127, 162, 0.3), transparent 68%);
  filter: blur(28px);
  animation: breathe 5.5s ease-in-out infinite;
}
.fallback-title {
  position: relative;
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.9);
}
.fallback-sub {
  position: relative;
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.45);
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.16); opacity: 1; }
}

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(16, 8, 12, 0.34) 0%,
    rgba(16, 8, 12, 0.06) 18%,
    rgba(16, 8, 12, 0) 46%,
    rgba(16, 8, 12, 0.14) 72%,
    rgba(16, 8, 12, 0.46) 100%
  );
}

/* 说话时人物外圈微光 */
.speaking-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  box-shadow: inset 0 0 130px rgba(255, 127, 162, 0.26);
}
.speaking-ring.on { opacity: 1; }

/* ---------- 通用玻璃 ---------- */
.glass,
.glass-btn,
.chat-panel,
.composer .bar,
.start-btn,
.drawer {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: var(--r-full);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}
.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255, 127, 162, 0.6);
  animation: pulse 2.4s ease-out infinite;
}
.brand.live .pulse { background: #5ef0a8; box-shadow: 0 0 0 0 rgba(94, 240, 168, 0.6); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 127, 162, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(255, 127, 162, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 127, 162, 0); }
}
.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.brand-state {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--faint);
  padding-left: 10px;
  border-left: 1px solid var(--stroke-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--r-full);
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.glass-btn:hover { background: var(--glass-solid); transform: translateY(-1px); }
.glass-btn:active { transform: translateY(0) scale(0.97); }
.glass-btn svg { width: 19px; height: 19px; }
.glass-btn.icon-only { width: 42px; padding: 0; }

.stop-btn {
  position: absolute;
  top: 20px; right: 78px;
  z-index: 31;
  color: rgba(255, 255, 255, 0.9);
}

/* ---------- 对话面板 ---------- */
.chat-panel {
  position: absolute;
  top: 84px; right: 24px; bottom: 24px;
  z-index: 25;
  width: 340px;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.32s ease;
}
.chat-panel.collapsed {
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px 13px;
  border-bottom: 1px solid var(--stroke-soft);
}
.chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.mini-btn {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.mini-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.12); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.chat-list::-webkit-scrollbar { width: 5px; }
.chat-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 99px;
}

.chat-empty {
  margin: auto;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.38);
}

.msg {
  max-width: 88%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.62;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}
.msg.her {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid var(--stroke-soft);
  border-bottom-left-radius: 5px;
  color: #fff;
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255, 127, 162, 0.86), rgba(232, 96, 138, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-bottom-right-radius: 5px;
  color: #fff;
}
.msg.sys {
  align-self: center;
  max-width: 100%;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.52);
  background: transparent;
  border: 0;
  text-align: center;
}
.msg.tool {
  align-self: center;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--r-full);
  padding: 6px 14px;
}

.typing {
  display: flex;
  gap: 4px;
  padding: 0 20px 16px;
}
.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: blink 1.3s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.panel-fab {
  position: absolute;
  right: 24px; bottom: 24px;
  z-index: 26;
}

/* ---------- 底部输入 ---------- */
.composer {
  position: absolute;
  left: 24px; right: 388px; bottom: 26px;
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.composer > * { pointer-events: auto; }

.composer .bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(560px, 100%);
  padding: 7px 7px 7px 20px;
  border-radius: var(--r-full);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
}
.composer input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: #fff;
  font-size: 14px;
  padding: 10px 0;
}
.composer input::placeholder { color: rgba(255, 255, 255, 0.5); }

.icon-btn,
.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  flex: none;
  transition: transform 0.18s ease, background 0.2s ease, color 0.2s ease;
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.92);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.24); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 127, 162, 0.22);
}
.icon-btn:disabled { opacity: 0.4; cursor: default; }

.send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 6px 18px rgba(232, 96, 138, 0.4);
}
.send-btn:hover { transform: translateY(-1px) scale(1.04); }
.send-btn svg { width: 20px; height: 20px; }

.quick-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.quick-chip {
  padding: 7px 15px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--stroke-soft);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.quick-chip:hover { background: rgba(255, 255, 255, 0.26); transform: translateY(-1px); }

/* ---------- 开始按钮 ---------- */
.start-btn {
  position: absolute;
  left: 50%; bottom: 40px;
  transform: translateX(-50%);
  z-index: 25;
  padding: 15px 40px;
  border-radius: var(--r-full);
  background: var(--glass-strong);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.14em;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease;
}
.start-btn:hover { transform: translateX(-50%) translateY(-2px); box-shadow: var(--shadow-lg); }
.start-btn:active { transform: translateX(-50%) scale(0.98); }
.start-btn[hidden] { display: none; }
.start-text { position: relative; z-index: 2; }
.start-glow {
  position: absolute;
  inset: -60% -20%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 127, 162, 0.45), transparent 62%);
  animation: breathe 4s ease-in-out infinite;
}
.start-btn.busy { pointer-events: none; opacity: 0.75; }

/* ---------- 设置抽屉 ---------- */
.drawer-mask {
  position: absolute;
  inset: 0;
  z-index: 39;
  background: rgba(14, 8, 11, 0.44);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  z-index: 40;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  border-radius: 26px 0 0 26px;
  border-right: 0;
  background: rgba(30, 22, 26, 0.72);
  backdrop-filter: blur(40px) saturate(170%);
  -webkit-backdrop-filter: blur(40px) saturate(170%);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--stroke-soft);
}
.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.1em; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  padding: 16px 17px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke-soft);
}
.card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.88);
}
.hint {
  margin: 0 0 12px;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.5);
}
.hint strong { color: var(--accent-soft); font-weight: 500; }

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.6);
}
.status-line b { color: #fff; font-weight: 500; }
.status-line b.ok { color: #6ef0b0; }
.status-line b.bad { color: #ff9b9b; }

.outfit-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.outfit-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke-soft);
}
.outfit-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.outfit-thumb {
  width: 44px; height: 44px;
  border-radius: 11px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--stroke-soft);
  flex: none;
}
.outfit-name { font-size: 13px; font-weight: 500; }
.outfit-state { font-size: 11px; color: rgba(255, 255, 255, 0.45); }
.outfit-state.good { color: #7fe6b0; }
.outfit-state.warn { color: #ffcf7a; }
.outfit-item input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--stroke-soft);
  color: #fff;
  font-size: 12px;
  outline: none;
}
.outfit-item input:focus { border-color: rgba(255, 127, 162, 0.6); }
.outfit-item input::placeholder { color: rgba(255, 255, 255, 0.32); }

select, .card > input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--stroke-soft);
  color: #fff;
  font-size: 12.5px;
  outline: none;
  margin-bottom: 10px;
  appearance: none;
}
select option { background: #2a2024; color: #fff; }

.ghost-btn {
  padding: 9px 18px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--stroke-soft);
  color: #fff;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.22); }
.ghost-btn.danger { color: #ffc2c2; border-color: rgba(255, 140, 140, 0.4); }
.ghost-btn.danger:hover { background: rgba(255, 90, 90, 0.22); }
.ghost-btn.selected { color: #b9ffcf; border-color: rgba(120, 255, 170, 0.45); background: rgba(80, 255, 150, 0.12); cursor: default; }

.upload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.upload-row input[type="file"] {
  flex: 1; min-width: 0;
  font-size: 12px; color: rgba(255, 255, 255, 0.7);
}
.upload-row .remember {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: rgba(255, 255, 255, 0.5); white-space: nowrap;
}
.upload-row .remember input { width: auto; margin: 0; }
.card > input#uploadName { margin-bottom: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%; bottom: 118px;
  transform: translateX(-50%) translateY(14px);
  z-index: 60;
  max-width: min(560px, 88vw);
  padding: 11px 20px;
  border-radius: var(--r-full);
  background: rgba(24, 14, 18, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--stroke-soft);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  line-height: 1.55;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 上传进度居中遮罩 ---------- */
.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 15, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.upload-modal {
  width: min(320px, 82vw);
  padding: 26px 24px 22px;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.upload-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-right-color: var(--accent-soft);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-label {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
}
.upload-track {
  width: 100%;
  height: 7px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.upload-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  transition: width 0.18s ease;
}
.upload-pct {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- 自适应 ---------- */
@media (max-width: 1180px) {
  .composer { right: 24px; }
  .chat-panel { box-shadow: var(--shadow-lg); }
}

@media (max-width: 860px) {
  .topbar { padding: 14px 16px; }
  .brand-state { display: none; }
  .chat-panel {
    top: 74px; right: 16px; bottom: 150px;
    width: min(340px, calc(100vw - 32px));
  }
  .composer { left: 16px; right: 16px; bottom: 18px; }
  .start-btn { bottom: 30px; padding: 14px 32px; font-size: 14px; }
  .stop-btn { top: 14px; right: 66px; }
  .quick-row { display: none; }
}
