* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #0b0d12; color: #e8eaed;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

/* ============ 登录页 ============ */
.login-screen {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1a2236 0%, #0b0d12 70%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: rgba(28, 32, 41, 0.9);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 36px 28px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  backdrop-filter: blur(10px);
  text-align: center;
}
.login-logo {
  font-size: 56px; line-height: 1; margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.login-card h1 {
  font-size: 22px; margin: 0 0 6px; color: #fff; font-weight: 700;
  letter-spacing: .5px;
}
.login-sub { font-size: 13px; color: #8a94a6; margin: 0 0 26px; }
#cardInput {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  background: #12151c;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  color: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#cardInput:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,.15);
}
#cardInput::placeholder {
  color: #4b5563; letter-spacing: 1px; text-transform: none;
}
.login-error {
  min-height: 20px; margin: 10px 0 6px;
  font-size: 13px; color: #f87171;
}
#loginBtn {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: 0; border-radius: 12px; cursor: pointer;
  transition: transform .1s, box-shadow .2s, opacity .2s;
  box-shadow: 0 8px 24px rgba(37,99,235,.35);
}
#loginBtn:hover:not(:disabled) { box-shadow: 0 10px 30px rgba(37,99,235,.5); }
#loginBtn:active:not(:disabled) { transform: scale(.98); }
#loginBtn:disabled { opacity: .6; cursor: not-allowed; }
.login-tip { margin: 18px 0 0; font-size: 12px; color: #5f6875; }

/* ============ 主界面 ============ */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.viewport { position: relative; flex: 0 0 42vh; background: #000; overflow: hidden; }
#video, #snapshot {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
#snapshot { display: none; }
#snapshot.show { display: block; animation: snapflash .3s ease; }
@keyframes snapflash {
  0% { opacity: 0; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,.6), transparent);
  font-size: 13px; color: #cdd3dd;
}
.hud-btn {
  background: rgba(255,255,255,.12); border: 0; color: #fff;
  width: 36px; height: 36px; border-radius: 50%; font-size: 16px;
  cursor: pointer; transition: background .2s;
}
.hud-btn:hover { background: rgba(255,255,255,.22); }

.skill-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: #12151c;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
#skillSelect {
  flex: 1;
  background: #1c2029; color: #e8eaed;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 8px 32px 8px 12px;
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%239aa4b2' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
#skillSelect:focus { border-color: #3b82f6; }
.time-left {
  font-size: 12px; color: #9aa4b2;
  white-space: nowrap; padding: 0 2px;
  font-variant-numeric: tabular-nums;
}
.btn-mini {
  width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: #1c2029; color: #9aa4b2;
  font-size: 15px; cursor: pointer;
  transition: background .2s, color .2s;
}
.btn-mini:hover { background: #252a35; color: #e8eaed; }

#chat {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
#chat::-webkit-scrollbar { width: 4px; }
#chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.msg {
  max-width: 82%; padding: 10px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.5; word-break: break-word;
  animation: fade .25s ease;
  white-space: pre-wrap;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.msg.user {
  align-self: flex-end;
  background: #2563eb; color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.bot {
  align-self: flex-start;
  background: #1c2029; color: #e8eaed;
  border-bottom-left-radius: 4px;
}
.msg.sys {
  align-self: center;
  background: transparent; color: #7a8494;
  font-size: 12px; padding: 4px 8px;
  text-align: center;
}
.msg.bot.streaming::after {
  content: '▊';
  animation: blink .8s step-start infinite;
  margin-left: 2px;
  color: #3b82f6;
  font-weight: 400;
}
@keyframes blink { 50% { opacity: 0; } }

.controls {
  display: flex; align-items: center; justify-content: center;
  gap: 18px; padding: 14px 18px 6px;
}
.btn-talk {
  flex: 1; max-width: 320px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; border: 0; border-radius: 40px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; font-size: 17px; font-weight: 600;
  transition: transform .1s, box-shadow .2s;
  box-shadow: 0 6px 20px rgba(37,99,235,.35);
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.btn-talk:active, .btn-talk.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 6px 20px rgba(220,38,38,.45);
  transform: scale(.97);
}
.btn-talk .mic { font-size: 20px; }
.btn-side {
  width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: #1c2029; color: #e8eaed;
  font-size: 22px; cursor: pointer;
  transition: background .2s;
}
.btn-side:hover { background: #252a35; }
.hint {
  text-align: center; font-size: 12px; color: #5f6875;
  padding: 0 0 12px;
}