:root {
  --bg: #0f1117; --panel: #171a23; --panel2: #1d2130; --border: #262a36;
  --text: #e8eaf0; --muted: #8b90a0; --accent: #7c8cff; --accent2: #ff7cc0;
  --user: #2a3148; --idol: #233a33; --danger: #e5484d; --ok: #3ecf8e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, "PingFang SC", "Noto Sans SC", sans-serif; }
#app { height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--muted); font-size: 13px; }

input, textarea, select, button { font: inherit; color: inherit; }
input, textarea, select { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; outline: none; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.danger { background: var(--danger); }
button.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 8px 0; }
label.check input { width: auto; margin-top: 3px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; cursor: pointer; background: var(--panel2); }
.chip.on { border-color: var(--accent); background: rgba(124,140,255,.15); }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #2a2f45; color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 50; max-width: 90vw; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel); }
.topbar h1 { flex: 1; font-size: 17px; margin: 0; }
.page { flex: 1; overflow-y: auto; padding: 14px; }

/* 首页 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: pointer; position: relative; }
.card .thumb { aspect-ratio: 1; background: var(--panel2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 32px; }
.card .meta { padding: 8px 10px; }
.card .meta b { display: block; }
.card .badge { position: absolute; top: 8px; left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.5); }
.card.sel { outline: 2px solid var(--accent); }
.card.add .thumb { font-size: 40px; color: var(--accent); }

/* 向导 */
.wizard { max-width: 560px; margin: 0 auto; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps i.on { background: var(--accent); }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; }
.guide { background: var(--panel2); border-radius: 10px; padding: 10px 12px; line-height: 1.8; font-size: 14px; }
.guide b { color: var(--accent2); }
.level { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.level > i { display: block; height: 100%; width: 0; background: var(--ok); }
.rec-btn { width: 100%; padding: 14px; font-size: 16px; }
.rec-btn.on { background: var(--danger); animation: pulse 1s infinite; }

/* 聊天 */
.chat { display: grid; grid-template-rows: 1fr auto; height: 100%; min-height: 0; }
.stage { position: relative; min-height: 0; background: radial-gradient(ellipse at 50% 30%, #1d2238, #0f1117 70%); display: flex; align-items: stretch; justify-content: center; gap: 2px; overflow: hidden; }
.stage.scene-set { background-size: cover; background-position: center; }
.stage canvas { flex: 1; min-width: 0; height: 100%; display: block; }
.stage canvas.speaking { filter: brightness(1.05); }
.stage .status { position: absolute; top: 10px; left: 10px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.4); padding: 4px 10px; border-radius: 999px; }
.stage .names { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: space-around; pointer-events: none; }
.stage .names span { font-size: 12px; background: rgba(0,0,0,.45); padding: 2px 10px; border-radius: 999px; }
.stage .names span.on { background: var(--accent); }
.stage .tools { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; }
.stage .tools button { padding: 6px 10px; font-size: 12px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.12); }
.stage .tools button.on { background: var(--accent); }
.panel { background: var(--panel); border-top: 1px solid var(--border); display: flex; flex-direction: column; max-height: 50dvh; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
.transcript { flex: 1; min-height: 70px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.idol { align-self: flex-start; background: var(--idol); border-bottom-left-radius: 4px; }
.msg.idol b { font-size: 12px; color: var(--muted); display: block; }
.msg.pending { color: var(--muted); font-style: italic; }
.composer { display: flex; gap: 8px; align-items: center; }
.composer input { flex: 1; }
.mic { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 20px; background: var(--border); user-select: none; -webkit-user-select: none; touch-action: none; flex: 0 0 auto; }
.mic.recording { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.6); } 50% { box-shadow: 0 0 0 10px rgba(229,72,77,0); } }

/* 侧面板（抽屉） */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; justify-content: flex-end; }
.drawer > div { width: min(480px, 100vw); background: var(--panel); height: 100%; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.drawer header { display: flex; align-items: center; gap: 8px; }
.drawer header h2 { flex: 1; margin: 0; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { background: var(--panel2); border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.item .t { flex: 1; min-width: 0; word-break: break-word; }
.item.off .t { opacity: .5; text-decoration: line-through; }

/* 游戏 */
.board { display: grid; gap: 0; background: #d9b36c; border-radius: 8px; padding: 6px; touch-action: manipulation; }
.board.gomoku { grid-template-columns: repeat(15, 1fr); aspect-ratio: 1; }
.board.gomoku .cell { position: relative; aspect-ratio: 1; cursor: pointer; }
.board.gomoku .cell::before, .board.gomoku .cell::after { content: ""; position: absolute; background: #6b4e1a; }
.board.gomoku .cell::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.board.gomoku .cell::after { top: 50%; left: 0; right: 0; height: 1px; }
.board.gomoku .cell.r0::before { top: 50%; } .board.gomoku .cell.r14::before { bottom: 50%; }
.board.gomoku .cell.c0::after { left: 50%; } .board.gomoku .cell.c14::after { right: 50%; }
.stone { position: absolute; inset: 12%; border-radius: 50%; z-index: 1; }
.stone.b { background: radial-gradient(circle at 35% 35%, #555, #000); }
.stone.w { background: radial-gradient(circle at 35% 35%, #fff, #bbb); }
.stone.last { box-shadow: 0 0 0 2px var(--accent); }
.board.xq { grid-template-columns: repeat(9, 1fr); aspect-ratio: 9/10; }
.board.xq .cell { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.board.xq .cell::before, .board.xq .cell::after { content: ""; position: absolute; background: #6b4e1a; }
.board.xq .cell::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.board.xq .cell::after { top: 50%; left: 0; right: 0; height: 1px; }
.board.xq .cell.r0::before { top: 50%; } .board.xq .cell.r9::before { bottom: 50%; }
.board.xq .cell.c0::after { left: 50%; } .board.xq .cell.c8::after { right: 50%; }
.board.xq .cell.river::before { display: none; }
.piece { width: 78%; height: 78%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: clamp(12px, 3.6vw, 20px); background: #f3e2b8; border: 2px solid #8a6a2a; z-index: 1; box-shadow: 1px 2px 3px rgba(0,0,0,.4); }
.piece.R { color: #c22; } .piece.B { color: #222; }
.piece.sel { outline: 3px solid var(--accent); }
.board.xq .cell.hint::after, .board.xq .cell.hint::before { background: #6b4e1a; }
.board.xq .cell.hint > .dot { width: 22%; height: 22%; border-radius: 50%; background: var(--accent); z-index: 2; opacity: .8; }
.ddz { display: flex; flex-direction: column; gap: 8px; }
.ddz .opp { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.ddz .table { min-height: 56px; background: var(--panel2); border-radius: 10px; padding: 8px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.cards { display: flex; flex-wrap: wrap; gap: 4px; }
.cardx { width: 40px; height: 56px; border-radius: 6px; background: #fff; color: #222; display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; border: 2px solid transparent; user-select: none; }
.cardx.red { color: #c22; }
.cardx.sel { transform: translateY(-8px); border-color: var(--accent); }
.cardx.sm { width: 30px; height: 42px; font-size: 13px; }
.game-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.game-head .muted { flex: 1; }
