/* realtime-agent 测试客户端样式 */
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif; background: #f5f6f8; color: #1c1e21; height: 100vh; }

.hidden { display: none !important; }
.error { color: #d93025; min-height: 1.2em; font-size: 13px; margin-top: 6px; }
.primary { background: #1668dc; color: #fff; border: none; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.primary:hover { background: #1157b8; }

/* 登录 */
.login-view { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08); width: 360px; }
.login-card h1 { font-size: 18px; margin: 0 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; }
.login-card input { padding: 9px 10px; border: 1px solid #d9dde3; border-radius: 6px; font-size: 14px; }
.login-card button { padding: 10px; border: none; border-radius: 6px; background: #1668dc; color: #fff; font-size: 15px; cursor: pointer; }
.login-card .hint { font-size: 12px; color: #6b7280; margin-top: 14px; }

/* 主布局 */
.main-view { display: flex; height: 100vh; }
.sidebar { width: 300px; background: #fff; border-right: 1px solid #e5e7eb; display: flex; flex-direction: column; }
.sidebar-head { padding: 12px; border-bottom: 1px solid #e5e7eb; display: flex; gap: 6px; align-items: center; }
.sidebar-head strong { flex: 1; }
.sidebar-head button { padding: 4px 8px; border: 1px solid #d9dde3; border-radius: 6px; background: #fff; cursor: pointer; }
.session-list { flex: 1; overflow-y: auto; padding: 8px; }
.session-item { padding: 10px; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.session-item:hover { background: #f8fafc; }
.session-item.active { border-color: #1668dc; background: #eef4ff; }
.session-item .row1 { display: flex; justify-content: space-between; align-items: center; }
.session-item .status { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.status.active { background: #dcfce7; color: #166534; }
.status.closed { background: #f3f4f6; color: #4b5563; }
.session-item .meta { font-size: 12px; color: #6b7280; margin-top: 4px; }
.del-btn { margin-top: 6px; padding: 3px 10px; border: 1px solid #fecaca; border-radius: 6px; background: #fef2f2; color: #b91c1c; cursor: pointer; font-size: 12px; }
.del-btn:hover { background: #fee2e2; }
.sidebar-foot { padding: 10px; border-top: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #4b5563; }
.sidebar-foot button { border: none; background: none; color: #d93025; cursor: pointer; }

/* 聊天 */
.chat { flex: 1; display: flex; flex-direction: column; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; background: #fff; }
.head-actions { display: flex; gap: 6px; align-items: center; }
.head-actions button { padding: 4px 10px; border: 1px solid #d9dde3; border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; }
.head-actions button:hover { background: #f3f4f6; }
.conn-state { font-size: 12px; color: #6b7280; }
.btn-history { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; margin-left: 8px; }
.btn-history:hover { background: #e0e7ff; }
.conn-state.connected { color: #166534; }
.event-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 70%; padding: 9px 12px; border-radius: 10px; line-height: 1.4; word-break: break-word; }
.msg.user { align-self: flex-end; background: #1668dc; color: #fff; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; }
/* source 区分：系统信息 / 恢复历史 */
.msg.system-info { align-self: center; background: #eef2ff; color: #3730a3; border: 1px dashed #c7d2fe; font-size: 0.9em; }
.msg.restore { align-self: center; background: #f3f4f6; color: #6b7280; border: 1px dashed #d1d5db; font-size: 0.9em; }
/* 故事播放 */
.mediarow { display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.media-label { font-size: 0.85em; color: #6b7280; }
.play-btn { padding: 5px 10px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; font-size: 0.85em; }
.play-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* 推荐故事列表 */
.story-list { display: flex; flex-wrap: wrap; gap: 6px; }
.story-list .story-btn { padding: 5px 10px; border: 1px solid #bbf7d0; border-radius: 6px; background: #f0fdf4; color: #14532d; cursor: pointer; font-size: 0.85em; }
.story-list .story-btn:hover { background: #dcfce7; }
.story-list .story-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.story-list .story-none { font-size: 0.85em; color: #9ca3af; }
.play-state { font-size: 0.85em; color: #1668dc; }
.agent-state { font-size: 0.85em; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: #f1f5f9; }
.agent-state[data-state="speaking"] { background: #dcfce7; color: #15803d; }
.agent-state[data-state="thinking"] { background: #fef3c7; color: #b45309; }
.agent-state[data-state="listening"] { background: #dbeafe; color: #1d4ed8; }
/* 按住说话 */
.ptt-btn { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; user-select: none; touch-action: none; }
.ptt-btn:active, .ptt-btn.active { background: #dc2626; color: #fff; border-color: #dc2626; }
.msg.story.subtitle { align-self: center; background: #fffbeb; color: #78350f; border: 1px solid #fde68a; font-size: 0.9em; width: 100%; }
.msg.story .story-title { font-weight: 600; margin-bottom: 4px; }
.msg.story .sub { padding: 2px 0; }
/* 静默推荐卡片 */
.msg.recommend { align-self: center; background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; width: 100%; }
.msg.recommend .r-title { font-weight: 600; margin-bottom: 6px; }
.msg.recommend .r-item { padding: 4px 0; }
.msg.recommend .r-link { color: #15803d; text-decoration: none; font-weight: 500; }
.msg.recommend .r-link:hover { text-decoration: underline; }
.msg.recommend .r-desc { font-size: 0.85em; color: #3f6212; margin-top: 2px; }
.evt { align-self: center; font-size: 12px; color: #6b7280; background: #f3f4f6; padding: 4px 10px; border-radius: 12px; font-family: ui-monospace, monospace; }
.history { font-size: 12px; opacity: 0.92; }
.msg.history { max-width: 88%; }
.tool-msg { align-self: flex-start; font-size: 12px; color: #7c3aed; background: #faf5ff; padding: 6px 10px; border-radius: 8px; font-family: ui-monospace, monospace; white-space: pre-wrap; }

.chat-foot { background: #fff; border-top: 1px solid #e5e7eb; padding: 10px 12px; }
.statusbar { display: flex; gap: 16px; align-items: center; font-size: 13px; color: #4b5563; margin-bottom: 8px; }
.statusbar select { padding: 4px 6px; border: 1px solid #d9dde3; border-radius: 6px; }
.inputrow { display: flex; gap: 8px; }
.inputrow input { flex: 1; padding: 10px; border: 1px solid #d9dde3; border-radius: 8px; font-size: 14px; }
.inputrow button { padding: 8px 14px; border: 1px solid #d9dde3; border-radius: 8px; background: #fff; cursor: pointer; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; }
.modal-card { background: #fff; padding: 24px; border-radius: 12px; width: 380px; max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 16px; font-size: 17px; }
.modal-card label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; margin-bottom: 12px; }
.modal-card select { padding: 7px; border: 1px solid #d9dde3; border-radius: 6px; }
.modal-card fieldset { border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions button { padding: 7px 14px; border: 1px solid #d9dde3; border-radius: 6px; background: #fff; cursor: pointer; }
