/* 三语翻译 · v3.1 视觉重构 */
:root {
  --pri: #07c160;
  --pri-deep: #059a4e;
  --pri-tint: #e8f9ef;
  --ink: #1a1d21;
  --ink-2: #5c6470;
  --ink-3: #9aa3ad;
  --line: #e9edf0;
  --bg: #f3f5f7;
  --card: #ffffff;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: calc(62px + env(safe-area-inset-bottom));
}

/* 顶栏 */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  padding: 13px 16px; font-size: 17px; font-weight: 600; letter-spacing: 1px;
  box-shadow: 0 1px 0 var(--line);
}
.hd-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0;
  color: #fff; background: linear-gradient(135deg, var(--pri), var(--pri-deep));
}
.hd-sub { font-size: 12px; font-weight: 400; color: var(--ink-3); letter-spacing: 2px; }

main { padding: 14px 14px 20px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fadeUp .18s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(16,40,80,.05); border: 1px solid rgba(0,0,0,.03);
}
.hidden { display: none !important; }
.muted { color: var(--ink-3); font-size: 13px; }

/* AI 配置提示条 */
.ai-banner {
  max-width: 640px; margin: 10px auto -4px; padding: 10px 16px;
  background: #fff7e6; color: #ad6800; font-size: 14px; border-radius: 12px; cursor: pointer;
}

/* 方向栏 */
.dir-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.badge { background: var(--pri-tint); color: var(--pri-deep); font-size: 13px; padding: 5px 12px; border-radius: 20px; font-weight: 500; }
.badge.muted { background: #f1f3f5; color: var(--ink-3); font-weight: 400; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: none; background: #f1f3f5; color: var(--ink-2);
  padding: 7px 18px; border-radius: 20px; font-size: 15px; cursor: pointer;
  transition: all .15s ease; font-weight: 500;
}
.chip:active { transform: scale(.96); }
.chip-active { background: linear-gradient(135deg, var(--pri), var(--pri-deep)); color: #fff; box-shadow: 0 3px 10px rgba(7,193,96,.3); }
.small-chips .chip { font-size: 13px; padding: 5px 13px; }
.provider-chips .chip { font-size: 14px; padding: 6px 14px; }

/* 输入区 */
textarea { width: 100%; min-height: 130px; border: none; resize: vertical; font-size: 16px; line-height: 1.65; outline: none; font-family: inherit; color: var(--ink); }
.input-ops { display: flex; align-items: center; gap: 8px; border-top: 1px solid #f1f3f5; padding-top: 10px; flex-wrap: wrap; }
.mini {
  border: 1px solid var(--line); background: #fafbfc; border-radius: 9px;
  padding: 6px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; transition: all .15s;
}
.mini:active { background: var(--pri-tint); color: var(--pri-deep); }
.mini:disabled { opacity: .55; }
.img-preview { margin-top: 10px; text-align: center; position: relative; }
.img-preview img { max-width: 100%; max-height: 200px; border-radius: 10px; border: 1px solid var(--line); }
.input-ops .muted { margin-left: auto; }

/* 选项行（表达风格 + 增强选项） */
.opt-row { display: flex; gap: 10px; margin: 2px 2px 12px; }
.opt-block { flex: 1; background: var(--card); border-radius: 14px; padding: 11px 13px; box-shadow: 0 1px 4px rgba(16,40,80,.05); border: 1px solid rgba(0,0,0,.03); }
.opt-label { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; font-weight: 500; }
.opt-checks { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; color: var(--ink-2); }
.opt-checks input { vertical-align: -2px; margin-right: 5px; accent-color: var(--pri); }

/* 按钮 */
.primary {
  display: block; width: 100%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--pri), var(--pri-deep));
  color: #fff; font-size: 17px; font-weight: 600; letter-spacing: 6px; text-indent: 6px;
  padding: 14px; border-radius: 14px; box-shadow: 0 6px 16px rgba(7,193,96,.28);
  transition: transform .1s ease, box-shadow .15s;
}
.primary:active { transform: scale(.985); box-shadow: 0 3px 8px rgba(7,193,96,.22); }
.primary:disabled { background: linear-gradient(135deg, #9fd8b4, #84c89d); box-shadow: none; }
.primary.small { width: auto; padding: 9px 20px; font-size: 15px; letter-spacing: 1px; text-indent: 0; box-shadow: none; }
.ghost { border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: 12px; padding: 9px 20px; font-size: 15px; cursor: pointer; }
.ghost.danger { color: #e24b4a; border-color: #f0c1c1; width: 100%; }
.ghost.full { width: 100%; margin-top: 4px; }
.ghost:disabled { opacity: .6; }

/* 输出区 */
.output { border-left: 4px solid var(--pri); animation: fadeUp .25s ease; }
.output-tag {
  display: inline-block; font-size: 12px; color: var(--pri-deep); background: var(--pri-tint);
  border-radius: 6px; padding: 2px 9px; margin-bottom: 9px; font-weight: 500;
}
.polished { background: #f8faf9; border: 1px dashed #d9e5dd; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.polished .plabel { display: block; font-size: 12px; color: var(--pri-deep); margin-bottom: 5px; font-weight: 500; }
.polished #polished-text { font-size: 14.5px; line-height: 1.65; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
#output-text { font-size: 16px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text; }
.output-ops { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* AI 助手 */
.chat-topbar {
  max-width: 640px; margin: 0 auto 8px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.chat-list { max-width: 640px; margin: 0 auto; padding: 4px 14px 96px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.bubble {
  max-width: 86%; padding: 11px 14px; border-radius: 16px; font-size: 15px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text;
}
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--pri), var(--pri-deep)); color: #fff; border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: 0 1px 3px rgba(16,40,80,.05); }
.bubble.thinking { color: var(--ink-3); }
.bubble.error { color: #e24b4a; }
.chat-empty { max-width: 640px; margin: 40px auto; text-align: center; line-height: 2.1; font-size: 14px; }
.chat-hello { font-size: 18px; color: var(--ink); font-weight: 600; margin-bottom: 6px; }
.chat-bar {
  position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 9;
  max-width: 640px; margin: 0 auto;
  padding: 9px 12px; background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-plus {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
  width: 42px; height: 42px; border-radius: 50%; font-size: 22px; line-height: 1; flex-shrink: 0;
  padding: 0;
}
.chat-plus:active { background: var(--pri-tint); color: var(--pri-deep); }
.chat-bar textarea {
  flex: 1; min-height: 42px; max-height: 120px; background: #fff;
  border: 1px solid var(--line); border-radius: 20px; padding: 10px 15px; font-size: 15px;
}
.chat-send {
  border: none; cursor: pointer; flex-shrink: 0;
  background: linear-gradient(135deg, var(--pri), var(--pri-deep)); color: #fff;
  font-size: 14px; font-weight: 500; padding: 11px 17px; border-radius: 20px;
}
.chat-send:disabled { opacity: .55; }
.chat-attach { display: flex; gap: 7px; flex-wrap: wrap; padding: 0 2px 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 46%;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 5px 8px 5px 12px; font-size: 12.5px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-x { border: none; background: #f1f3f5; color: var(--ink-3); border-radius: 50%; width: 17px; height: 17px; font-size: 10px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.chat-thumb { display: block; max-width: 180px; max-height: 120px; border-radius: 10px; margin-bottom: 6px; }
.file-tag {
  display: inline-block; background: rgba(255,255,255,.22); border-radius: 8px;
  padding: 3px 9px; font-size: 12.5px; margin: 0 5px 5px 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top;
}
.bubble.assistant .file-tag { background: #f4f6f7; }

/* 历史页 */
.search-box { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 15px; margin-bottom: 12px; outline: none; background: #fff; }
.search-box:focus { border-color: var(--pri); }
.segment { display: flex; background: #fff; border-radius: 12px; padding: 4px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(16,40,80,.05); }
.seg { flex: 1; border: none; background: transparent; color: var(--ink-2); padding: 9px; border-radius: 9px; font-size: 15px; cursor: pointer; }
.seg-active { background: linear-gradient(135deg, var(--pri), var(--pri-deep)); color: #fff; }
.hist-item { background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(16,40,80,.05); border: 1px solid rgba(0,0,0,.03); }
.hist-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; flex-wrap: wrap; }
.dir-tag { font-size: 12px; color: var(--pri-deep); background: var(--pri-tint); padding: 2px 10px; border-radius: 6px; }
.fav-mark { color: #f5a623; font-size: 14px; }
.img-mark { font-size: 13px; }
.hist-time { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.hist-summary { font-size: 15px; color: var(--ink); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hist-detail { margin-top: 10px; border-top: 1px solid #f1f3f5; padding-top: 10px; }
.hist-detail .label { display: block; font-size: 12px; color: var(--ink-3); margin: 8px 0 4px; }
.hist-detail .text { font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text; }
.hist-ops { display: flex; gap: 8px; margin-top: 12px; }
.hist-ops button { border: 1px solid var(--line); background: #fafbfc; border-radius: 8px; padding: 5px 14px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.empty { text-align: center; padding: 80px 0; }

/* 设置页 */
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.about { text-align: center; line-height: 1.9; }
.help-text { font-size: 13px; color: var(--ink-3); line-height: 1.65; background: #f8faf9; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.text-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 15px; outline: none; background: #fff; color: var(--ink); }
.text-input:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(7,193,96,.12); }
.key-row { display: flex; gap: 8px; }
.key-row .text-input { flex: 1; }
.key-row .mini { flex-shrink: 0; }

/* 底部导航 */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; border: none; background: transparent; padding: 12px 0 10px; font-size: 14px; color: var(--ink-3); cursor: pointer; }
.tab-active { color: var(--pri-deep); font-weight: 600; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20,26,32,.82); color: #fff; padding: 10px 20px; border-radius: 22px;
  font-size: 14px; z-index: 99; max-width: 86vw; text-align: center;
  animation: fadeUp .2s ease;
}
