/* style.css - 中哈快译通 H5 商务简洁风格 */
:root {
  --primary: #1668dc;
  --primary-dark: #0f4fae;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2733;
  --muted: #6b7686;
  --border: #e3e8f0;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(16, 42, 94, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  display: flex; flex-direction: column;
}

/* 广告位 */
.ad-banner { height: 56px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.ad-placeholder {
  background: repeating-linear-gradient(45deg, #faf3d8, #faf3d8 14px, #fbf7e3 14px, #fbf7e3 28px);
  color: #9a8308; border-bottom: 1px solid #efe3ad;
}
#ad-bottom { border-top: 1px solid #efe3ad; margin-top: auto; }
.ad-tag { font-size: 11px; color: #b0a24b; margin-right: 6px; border: 1px solid #d8cb85; border-radius: 4px; padding: 0 4px; }

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #3b9afe);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; box-shadow: var(--shadow);
}
.brand h1 { font-size: 18px; font-weight: 700; }
.brand p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* 控件 */
.ui-select, .select-box select {
  appearance: none; background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; color: var(--text); cursor: pointer; outline: none;
}
.ui-select:focus, .select-box select:focus { border-color: var(--primary); }

/* 认证区域 */
.auth-area .link-btn {
  background: none; border: none; color: var(--primary); font-size: 14px; cursor: pointer; padding: 6px 8px;
}
.auth-area .user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
}
.auth-area .user-chip button {
  background: none; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer;
}

/* 主体 */
.container { width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 16px; flex: 1; }

/* Tab */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
  flex: 1; padding: 12px; border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 语种选择行 */
.selectors { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.select-box { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.select-box span { font-size: 12px; color: var(--muted); }
.select-box select { width: 100%; padding: 10px 12px; font-size: 15px; }
.swap-btn {
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 50%; background: var(--card);
  color: var(--primary); font-size: 18px; cursor: pointer; margin-top: 18px; transition: transform .2s;
}
.swap-btn:hover { transform: rotate(180deg); }

/* 双栏卡片 */
.columns { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .columns { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.card-tools { display: flex; justify-content: space-between; align-items: center; min-height: 24px; }
.tts-tag { font-size: 11px; color: #d98a00; background: #fdf3e2; border-radius: 6px; padding: 2px 8px; }
textarea {
  width: 100%; border: none; resize: none; font-size: 16px; line-height: 1.6; outline: none; color: var(--text);
  background: transparent; min-height: 160px;
}
.result-area {
  font-size: 16px; line-height: 1.6; min-height: 160px; color: var(--text); white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto;
}
.result-area.placeholder { color: #aab3c0; }
.card-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.char-count { font-size: 12px; color: var(--muted); margin-right: auto; }
.tool-btn {
  background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn:disabled { opacity: .4; cursor: not-allowed; }

/* 主按钮 */
.btn-primary {
  width: 100%; padding: 14px; margin-top: 16px; background: linear-gradient(135deg, var(--primary), #3b9afe);
  color: #fff; border: none; border-radius: var(--radius); font-size: 17px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .5; cursor: wait; }

/* 状态 */
.status { margin-top: 12px; font-size: 13px; text-align: center; }
.status.error { color: #d2433c; }
.status.loading { color: var(--primary); }

/* 拍照 */
.photo-card { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.photo-tip { color: var(--muted); font-size: 14px; }
.photo-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 120px; padding: 18px;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--card); cursor: pointer; font-size: 14px; color: var(--muted);
}
.photo-btn:hover { border-color: var(--primary); color: var(--primary); }
.photo-btn span:first-child { font-size: 32px; }
.photo-preview { max-width: 100%; max-height: 300px; border-radius: var(--radius); border: 1px solid var(--border); }
.photo-langs { display: flex; gap: 12px; width: 100%; }
.photo-langs .select-box { flex: 1; }
.photo-results { display: grid; grid-template-columns: 1fr; gap: 12px; width: 100%; }
@media (min-width: 640px) { .photo-results { grid-template-columns: 1fr 1fr; } }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card); border-radius: 16px; padding: 24px; width: 100%; max-width: 400px;
  position: relative; box-shadow: 0 12px 40px rgba(15, 23, 42, .25); max-height: 90vh; overflow-y: auto;
}
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; }
.modal-box h2 { font-size: 20px; margin-bottom: 16px; text-align: center; }
.form-item { margin-bottom: 12px; }
.form-item label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-item input, .form-item select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; outline: none; background: #fbfcfe;
}
.form-item input:focus, .form-item select:focus { border-color: var(--primary); }
.form-item select { appearance: auto; }
.auth-error { color: #d2433c; font-size: 13px; margin: 8px 0; min-height: 18px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 12px; }
.auth-switch a { color: var(--primary); cursor: pointer; }

/* 底部 */
.footer { text-align: center; padding: 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); background: var(--card); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: rgba(31, 39, 51, .92); color: #fff;
  padding: 10px 20px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow);
}
.toast.hidden { display: none; }

.hidden { display: none !important; }
.text-center { text-align: center; }

/* AI 快捷回复 */
.reply-bar { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 4px; }
.reply-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.reply-head span { font-weight: 600; }
#reply-list, #talk-reply-list { display: flex; flex-direction: column; gap: 8px; }
.reply-item {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; text-align: left;
  background: #f6f9ff; border: 1px solid #dbe7ff; border-radius: 9px;
  padding: 9px 12px; font-size: 14px; line-height: 1.5; color: var(--text); cursor: pointer;
}
.reply-item:hover { border-color: var(--primary); background: #eef4ff; }
.reply-tag {
  flex: none; width: 20px; height: 20px; border-radius: 6px; background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}

/* 实时对话 */
.talk-card { display: flex; flex-direction: column; gap: 14px; }
.talk-btn { min-height: 64px; border-radius: 32px; font-size: 18px; font-weight: 600; }
/* "检测我的浏览器"入口(面板内独立样式,不依赖 .auth-area 作用域) */
.bw-check-btn {
  background: none; border: none; color: var(--primary); font-size: 13px; cursor: pointer; padding: 6px 8px;
}
.bw-check-btn:active { opacity: .6; }
.talk-tools { display: flex; align-items: center; justify-content: space-between; }
.talk-tools-right { display: flex; gap: 4px; }

/* 双说话按钮:对方(左,白底蓝字) / 我(右,蓝底白字),录音中变红 */
.talk-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.talk-half {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 76px; border-radius: 14px; font-size: 16px; font-weight: 600; cursor: pointer; padding: 8px 6px; line-height: 1.25;
}
.talk-half .th-mic { font-size: 20px; }
.talk-half .th-sub { font-size: 11px; font-weight: 400; opacity: .75; }
.talk-half-them { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.talk-half-me { background: var(--primary); color: #fff; border: 2px solid var(--primary); }
.talk-half.recording {
  background: linear-gradient(135deg, #d2433c, #f0643b) !important; color: #fff !important; border-color: #d2433c !important;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 4px rgba(210,67,60,.25); } 50% { box-shadow: 0 0 0 10px rgba(210,67,60,.08); } }

/* 麦克风失败修复按钮组(重试/重新授权/打开系统设置/刷新页面) */
.talk-mic-fix { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.talk-mic-fix button {
  border: 1px solid var(--primary); background: #fff; color: var(--primary);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.talk-mic-fix button:active { background: var(--primary); color: #fff; }

/* 微信式对话气泡区 */
.talk-chat {
  height: 340px; overflow-y: auto; background: #f2f4f7; border-radius: 12px; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-empty { margin: auto; color: #9aa3af; font-size: 13px; text-align: center; line-height: 1.7; }
.msg { display: flex; max-width: 100%; }
.msg-them { justify-content: flex-start; }
.msg-me { justify-content: flex-end; }
.bubble { max-width: 82%; border-radius: 12px; padding: 8px 12px; position: relative; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.msg-them .bubble { background: #fff; border-top-left-radius: 3px; }
.msg-me .bubble { background: var(--primary); color: #fff; border-top-right-radius: 3px; }
.msg-src { font-size: 12px; line-height: 1.5; opacity: .68; margin-bottom: 3px; word-break: break-word; }
.msg-dst { font-size: 15px; line-height: 1.55; word-break: break-word; }
.msg-tools { display: flex; align-items: center; gap: 10px; margin-top: 5px; font-size: 12px; opacity: .8; }
.msg-tools button { background: none; border: none; cursor: pointer; font-size: 13px; padding: 0; color: inherit; opacity: .85; }
.msg-tools button:active { opacity: .5; }
.msg-tools .isaved { opacity: 1; }
.msg-time { opacity: .6; }
.talk-boxes { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .talk-boxes { grid-template-columns: 1fr 1fr; } }
.talk-live { min-height: 120px; border-radius: 8px; background: #fbfcfe; border: 1px solid var(--border); padding: 10px; }