:root {
  --bg: #0f1115;
  --fg: #ffffff;
  --fg-dim: rgba(255, 255, 255, .72);
  --fg-faint: rgba(255, 255, 255, .45);
  --surface: rgba(255, 255, 255, .14);
  --surface-strong: rgba(255, 255, 255, .24);
  --green: #07c160;
  --red: #fa5151;
  --accent: #2f7cf6;
  --page: #f4f6f9;
  --ink: #1d2129;
  --ink-dim: #6b7280;
  --card: #ffffff;
  --line: #e5e7eb;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
[hidden] { display: none !important; }   /* 防止 display:flex 等样式盖掉 hidden 属性 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { background: var(--page); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font: inherit; border: none; background: none; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------------ 首页 */
.home { min-height: 100%; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 28px) 20px calc(var(--safe-bottom) + 24px); max-width: 560px; margin: 0 auto; }
.home .profile { display: flex; gap: 16px; align-items: center; }
.home .profile img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.home .profile h1 { font-size: 22px; font-weight: 600; }
.home .profile p { font-size: 14px; color: var(--ink-dim); margin-top: 4px; }
.home .intro { margin-top: 18px; font-size: 14px; line-height: 1.7; color: var(--ink-dim); }
.home .tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.home .tags span { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #e8f0fe; color: #1f5fd1; }
.home .entries { margin-top: 28px; display: grid; gap: 14px; }
.entry { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.entry .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.entry .ico svg { width: 26px; height: 26px; fill: #fff; }
.entry.chat .ico { background: var(--green); }
.entry.assess .ico { background: var(--accent); }
.entry h2 { font-size: 17px; font-weight: 600; }
.entry p { font-size: 13px; color: var(--ink-dim); margin-top: 3px; line-height: 1.5; }
.entry .go { margin-left: auto; color: #c0c4cc; font-size: 22px; }
.home .avatar-pick { margin-top: 22px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-dim); }
.seg { display: inline-flex; background: #e9ecf1; border-radius: 10px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--ink-dim); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.home .note { margin-top: auto; padding-top: 28px; font-size: 12px; line-height: 1.6; color: #9aa0a8; text-align: center; }

/* ------------------------------------------------------------------ 通话页 */
.call { position: fixed; inset: 0; background: var(--bg); color: var(--fg); overflow: hidden; }
.call .stage { position: absolute; inset: 0; }
.call .stage video.bg { position: absolute; inset: -6%; width: 112%; height: 112%; object-fit: cover; object-position: 50% 80%; filter: blur(22px) brightness(.92); }
.call .stage video.fg { position: absolute; object-fit: cover; background: transparent; -webkit-mask-image: linear-gradient(#000 82%, transparent); mask-image: linear-gradient(#000 82%, transparent); }
.call .stage canvas.live { position: absolute; opacity: 0; transition: opacity .25s; -webkit-mask-image: linear-gradient(#000 82%, transparent); mask-image: linear-gradient(#000 82%, transparent); }
.call .stage canvas.live.on { opacity: 1; transition: opacity .06s; }
.call .stage video, .call .stage img.full { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; display: block; background: #f6f6f6; }
.call .shade-top { position: absolute; left: 0; right: 0; top: 0; height: 120px; background: linear-gradient(rgba(0,0,0,.35), transparent); pointer-events: none; }
.call .shade-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 62%; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.45) 35%, rgba(0,0,0,.82)); pointer-events: none; }

.call .topbar { position: absolute; top: calc(var(--safe-top) + 10px); left: 16px; right: 16px; display: flex; align-items: center; gap: 10px; }
.call .topbar .who { font-size: 16px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.call .topbar .timer { font-size: 13px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.call .topbar .spacer { flex: 1; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.3); }
.icon-btn svg { width: 18px; height: 18px; fill: #fff; }

.call .progress { position: absolute; top: calc(var(--safe-top) + 52px); left: 16px; right: 16px; display: none; }
.call .progress .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; }
.call .progress .bar i { display: block; height: 100%; width: 0; background: #fff; transition: width .4s; }
.call .progress .label { font-size: 12px; color: var(--fg-dim); margin-top: 6px; }
.call.assess .progress { display: block; }

.call .subs { position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 148px); max-height: 36vh; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; overflow: hidden; -webkit-mask-image: linear-gradient(transparent, #000 24px); mask-image: linear-gradient(transparent, #000 24px); }
.call .subs.hidden { visibility: hidden; }
.line { font-size: 18px; line-height: 1.55; text-shadow: 0 1px 2px rgba(0,0,0,.8), 0 0 10px rgba(0,0,0,.5); }
.line.user { font-size: 15px; color: var(--fg-dim); align-self: flex-end; text-align: right; max-width: 85%; }
.line.user.partial { color: var(--fg-faint); }
.line.bot { max-width: 92%; }
.line.note { font-size: 13px; color: var(--fg-faint); align-self: center; }

.call .controls { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 30px); display: flex; justify-content: space-evenly; align-items: flex-start; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-dim); min-width: 72px; }
.ctl .round { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: transform .15s, background .2s; }
.ctl .round:active { transform: scale(.94); }
.ctl .round svg { width: 28px; height: 28px; fill: #fff; }
.ctl.on .round { background: #fff; }
.ctl.on .round svg { fill: #111; }
.ctl.hang .round { background: var(--red); }
.ctl.accept .round { background: var(--green); }

/* 来电 / 结束 覆盖层 */
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; background: rgba(15,17,21,.55); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); padding: calc(var(--safe-top) + 14vh) 24px calc(var(--safe-bottom) + 40px); text-align: center; }
.overlay[hidden] { display: none; }
.overlay img.ava { width: 96px; height: 96px; border-radius: 16px; object-fit: cover; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.overlay h2 { font-size: 24px; font-weight: 600; margin-top: 18px; }
.overlay p { font-size: 14px; color: var(--fg-dim); margin-top: 8px; line-height: 1.6; }
.overlay .hint { margin-top: 18px; font-size: 12px; color: var(--fg-faint); max-width: 320px; }
.overlay .actions { margin-top: auto; display: flex; gap: 72px; }
.overlay .actions.col { flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 500; background: var(--surface-strong); text-align: center; }
.btn.primary { background: var(--green); }
.ring { animation: ring 1.6s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* 写实卡通 2.5D */
.call .stage img.cartoon-bg { position: absolute; inset: -6%; width: 112%; height: 112%; object-fit: cover; object-position: 50% 85%; filter: blur(22px) brightness(.95); }
.call .stage canvas.cartoon-gl, .call .stage canvas.cartoon-mouth { position: absolute; -webkit-mask-image: linear-gradient(#000 82%, transparent); mask-image: linear-gradient(#000 82%, transparent); }

/* 卡通形象动画（2.5D 加载失败时的立绘版本） */
.cartoon-wrap { position: absolute; inset: 0; overflow: hidden; background: #f7f7f5; }
.cartoon-wrap img { position: absolute; left: 50%; top: 0; height: 100%; min-width: 100%; object-fit: cover; object-position: 50% 15%; transform-origin: 50% 70%; transform: translateX(-50%); will-change: transform; }

/* ------------------------------------------------------------------ 后台 */
.admin { max-width: 720px; margin: 0 auto; padding: 24px 16px 80px; }
.admin h1 { font-size: 22px; }
.admin .sub { color: var(--ink-dim); font-size: 13px; margin-top: 6px; line-height: 1.6; }
.admin form { margin-top: 18px; display: grid; gap: 14px; }
.field { background: var(--card); border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.field label { display: block; font-size: 14px; font-weight: 500; }
.field .meta { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.field select, .field input[type=text], .field input[type=number], .field textarea { margin-top: 10px; width: 100%; font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.field textarea { min-height: 120px; line-height: 1.6; resize: vertical; }
.field textarea.long { min-height: 360px; font-size: 13px; }
.field .range { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.field .range input { flex: 1; }
.field .range output { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.field .row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.admin .bar { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 0; background: linear-gradient(transparent, var(--page) 30%); }
.admin .bar button { flex: 1; padding: 12px; border-radius: 10px; font-size: 15px; background: #e9ecf1; }
.admin .bar button.primary { background: var(--accent); color: #fff; }
.small-btn { padding: 7px 12px; border-radius: 8px; background: #e9ecf1; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 9; }
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; }
.login input { width: 100%; margin: 16px 0 10px; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; }
