/* 由 sync-lib.mjs 从 ../renderer/style.css 生成，不要直接改 */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0a66ff;
  --accent-soft: rgba(10, 102, 255, 0.1);
  --ok: #34c759;
  --err: #e5484d;
  --err-soft: rgba(229, 72, 77, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --surface: #2c2c2e;
    --surface-2: #3a3a3c;
    --text: #f2f2f7;
    --text-2: #aeaeb2;
    --text-3: #6e6e73;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #4c8dff;
    --accent-soft: rgba(76, 141, 255, 0.16);
    --err-soft: rgba(229, 72, 77, 0.14);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--text-3); font-size: 11.5px; }

/* 标题栏：左侧留给红绿灯，整条可拖动 */
.titlebar {
  height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 80px; -webkit-app-region: drag; user-select: none;
}
.title { font-weight: 600; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.title .logo { width: 22px; height: 22px; margin: 0 -2px; }
.titlebar-actions { display: flex; gap: 2px; -webkit-app-region: no-drag; }
.icon-btn {
  width: 28px; height: 28px; border: none; background: transparent; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* 来源：截图缩略图 / 选中的文字 */
.source { flex: none; padding: 0 14px 10px; }
.shot-row { display: flex; gap: 8px; align-items: stretch; }
.shot-row:has(.shots[hidden]) { display: none; }
.shot-actions { flex: none; display: flex; flex-direction: column; gap: 6px; width: 104px; }
.shot-actions[hidden] { display: none; }
.mini-btn {
  flex: 1; display: flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 8px;
  border: 1px dashed var(--text-3); background: transparent; color: var(--text-2); font-size: 12px; white-space: nowrap;
}
.mini-btn svg { width: 14px; height: 14px; }
.mini-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.shots { flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.shot {
  position: relative; flex: none; width: 92px; height: 66px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface); cursor: zoom-in;
}
.shot.long { width: 52px; }
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.shot .badge {
  position: absolute; left: 4px; bottom: 4px; padding: 0 5px; border-radius: 4px; font-size: 10px; line-height: 16px;
  background: rgba(0, 0, 0, 0.6); color: #fff;
}
.shot .remove {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, 0.6); color: #fff; display: none; align-items: center; justify-content: center; padding: 0;
}
.shot .remove svg { width: 11px; height: 11px; }
.shot:hover .remove { display: inline-flex; }
.lightbox {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.72); overflow: auto; padding: 48px 20px 20px; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { display: block; max-width: 100%; margin: 0 auto; border-radius: 6px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); }
.quote {
  margin-top: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  color: var(--text-2); white-space: pre-wrap; max-height: 96px; overflow: auto;
}

/* 模型选择 + 补充要求 */
.controls {
  position: sticky; top: 0; z-index: 5; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips-label { font-size: 11.5px; color: var(--text-3); margin-right: 2px; }
.chip-count { font-size: 10.5px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chip.on .chip-count { background: var(--accent); color: #fff; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px;
  font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.on::before { background: var(--accent); }
.prompt { display: flex; gap: 8px; }
.prompt input {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; outline: none;
}
.prompt input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.primary {
  height: 32px; padding: 0 12px; border-radius: 8px; border: none; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 500;
}
.primary:hover { filter: brightness(1.08); }

/* 结果卡片 */
.scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
main { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
main:empty { display: none; }
.card { position: relative; flex: none; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.card.loading .dot { background: var(--text-3); animation: pulse 1.2s ease-in-out infinite; }
.card.error .dot { background: var(--err); }
.card-name { font-weight: 600; }
.card-meta { color: var(--text-3); font-size: 11.5px; flex: 1; }
.card-head .icon-btn { width: 26px; height: 26px; }
.card-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 4px; }

.draft {
  position: relative; display: flex; gap: 8px; align-items: flex-start; padding: 8px 8px 8px 10px; border-radius: 8px;
  transition: background 0.12s;
}
.draft:hover { background: var(--surface-2); }
.draft .num {
  flex: none; margin-top: 2px; min-width: 22px; height: 18px; padding: 0 4px; border-radius: 4px; font-size: 10.5px;
  color: var(--text-3); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center;
}
.draft .text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; border-radius: 4px; cursor: text; font-size: 13.5px; }
.draft .text:focus { box-shadow: 0 0 0 2px var(--accent-soft); background: var(--surface); }
.copy {
  flex: none; height: 26px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2);
}
.copy svg { width: 14px; height: 14px; }
.draft:hover .copy, .copy:focus-visible { border-color: var(--accent); color: var(--accent); }
.copy.done { background: var(--ok); border-color: var(--ok); color: #fff; }

.note { margin: 2px 4px 0; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 12px; white-space: pre-wrap; }
.mem { margin: 2px 4px 0; display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 8px; border-radius: 6px; border: 1px dashed var(--line); }
.mem-label { font-size: 11.5px; color: var(--text-3); flex: none; }
.mem input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--text); font: inherit; font-size: 12.5px;
  padding: 3px 4px; border-radius: 4px; outline: none;
}
.mem input:focus { background: var(--surface-2); }
.mem .link { border: none; background: transparent; color: var(--accent); font-size: 12px; padding: 3px 6px; border-radius: 5px; }
.mem .link:hover { background: var(--accent-soft); }
.mem .link.ghost { color: var(--text-3); }
.mem.saved { border-style: solid; }
.mem.saved input { color: var(--text-2); }

.err { margin: 0 4px; padding: 8px 10px; border-radius: 6px; background: var(--err-soft); color: var(--err); font-size: 12px; white-space: pre-wrap; word-break: break-all; }

.skeleton { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.skeleton i { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton i:nth-child(2) { width: 70%; }
.skeleton i:nth-child(3) { width: 45%; }

/* 空状态 */
.empty { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; color: var(--text-2); padding: 20px; }
.empty[hidden] { display: none; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.kbd-row { display: flex; align-items: center; gap: 12px; width: 340px; }
.kbd { min-width: 96px; text-align: right; font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-2); }
.problem { margin-top: 10px; max-width: 360px; padding: 8px 10px; border-radius: 8px; background: var(--err-soft); color: var(--err); font-size: 12px; text-align: center; }

.statusbar { flex: none; height: 28px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-top: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); max-width: calc(100% - 40px);
  padding: 8px 14px; border-radius: 8px; background: rgba(30, 30, 32, 0.92); color: #fff; font-size: 12.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2); z-index: 10;
}
.toast.error { background: var(--err); }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 模式 ---------- */
.modes { flex: none; display: flex; gap: 2px; margin: 0 14px 10px; padding: 3px; border-radius: 9px; background: var(--surface-2); }
.mode { flex: 1; height: 26px; border: none; border-radius: 7px; background: transparent; color: var(--text-2); font-size: 12.5px; }
.mode:hover { color: var(--text); }
.mode.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ---------- 上下文条 ---------- */
.context-bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 0 14px 10px; }
.context-bar.dim .ctx-persona, .context-bar.dim .ctx-people { opacity: 0.4; }
.ctx-app { font-size: 12px; color: var(--text-2); padding: 3px 8px; border-radius: 6px; background: var(--surface-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-persona { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); }
.ctx-persona select, .analysis-head select {
  font: inherit; font-size: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px;
}
.ctx-people { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.person { display: inline-flex; align-items: center; border-radius: 999px; border: 1px dashed var(--text-3); overflow: hidden; }
.person.known { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.person-main { display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent; padding: 2px 10px 2px 8px; font-size: 12px; color: var(--text); }
.person-main svg { width: 13px; height: 13px; color: var(--text-2); }
.person.known .person-main svg { color: var(--accent); }
.person-name { font-weight: 600; }
.person-sub { color: var(--text-2); font-size: 11.5px; }
.person-act { border: none; border-left: 1px solid var(--line); background: transparent; color: var(--accent); width: 26px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.person-act svg { width: 13px; height: 13px; }
.person-act:hover { background: var(--accent-soft); }

/* ---------- 语气按钮 ---------- */
.tone-row { display: flex; gap: 6px; align-items: flex-start; }
.tones { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.tone {
  height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-size: 12px;
}
.tone:hover { border-color: var(--text-3); color: var(--text); }
.tone.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.link-btn { border: none; background: transparent; color: var(--accent); font-size: 12px; height: 26px; padding: 0 4px; }

/* ---------- 名次 ---------- */
.rank { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.rank.top { background: linear-gradient(135deg, #ffcf4d, #ff9f1a); color: #4a2a00; font-weight: 600; }

/* ---------- 解读 ---------- */
.analysis { margin: 12px 14px 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; flex: none; }
.analysis-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 6px; border-bottom: 1px solid var(--line); }
.analysis-title { flex: 1; display: flex; align-items: center; gap: 6px; border: none; background: transparent; font-weight: 600; text-align: left; padding: 4px 6px; border-radius: 6px; }
.analysis-title:hover { background: var(--surface-2); }
.analysis-title svg { color: #8e5cff; }
.analysis-body { padding: 4px 14px 10px; }
.analysis.collapsed .analysis-body, .analysis.collapsed .analysis-foot { display: none; }
.analysis.collapsed .analysis-head { border-bottom: none; }
.analysis-foot { padding: 0 12px 10px; }
.secondary { height: 28px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-size: 12.5px; }
.secondary:hover { filter: brightness(1.05); }

/* ---------- 学到的习惯 ---------- */
.learn { margin: 12px 14px 0; padding: 10px 12px; border-radius: var(--radius); border: 1px solid #ffcf4d; background: rgba(255, 207, 77, 0.12); display: flex; flex-direction: column; gap: 6px; flex: none; }
.learn-head { display: flex; justify-content: space-between; align-items: center; }
.learn-title { font-weight: 600; }

/* ---------- Markdown ---------- */
.md { font-size: 13px; line-height: 1.6; }
.md h2, .md h3, .md h4 { margin: 12px 0 4px; font-size: 13.5px; }
.md h2 { font-size: 14px; }
.md p { margin: 4px 0; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.md-table { overflow-x: auto; margin: 6px 0; }
.md table { border-collapse: collapse; font-size: 12px; width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; overflow-wrap: anywhere; white-space: normal; }
.md th { background: var(--surface-2); }
.note.md { background: transparent; color: var(--text); padding: 2px 6px; }
.section-label { margin: 8px 6px 0; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.mem { flex-wrap: wrap; }

/* ---------- 换行 ---------- */
.card-body, .note, .md, .md p, .md li, .err, .quote, .analysis-body { min-width: 0; overflow-wrap: anywhere; }
.card-head { flex-wrap: wrap; }
.card-meta { min-width: 0; }

/* ---------- 记住：右上角气泡 + 浮层 ---------- */
.mem-wrap { position: relative; }
.mem-bubble {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 6px; border-radius: 999px;
  border: 1px solid #ffcf4d; background: rgba(255, 207, 77, 0.16); color: #9a6400; font-size: 11.5px;
}
.mem-bubble svg { width: 13px; height: 13px; }
.mem-bubble:hover { background: rgba(255, 207, 77, 0.3); }
.mem-bubble.done { border-color: var(--line); background: var(--surface-2); color: var(--text-3); }
.mem-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #ff9f1a; color: #fff; font-size: 10.5px; display: inline-flex; align-items: center; justify-content: center; }
.mem-bubble.done .mem-count { background: transparent; color: var(--ok); }
@media (prefers-color-scheme: dark) { .mem-bubble { color: #ffcf4d; } }
.mem-pop {
  position: absolute; top: 30px; right: -36px; z-index: 30; width: min(400px, calc(100vw - 40px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.mem-pop[hidden] { display: none; }
.mem-pop-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; font-weight: 600; font-size: 12.5px; }
.mem-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.mem { flex-direction: column; align-items: stretch; gap: 4px; margin: 0; padding: 6px 8px; }
.mem textarea {
  width: 100%; resize: none; overflow: hidden; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 12.5px; line-height: 1.5; padding: 2px 4px; border-radius: 4px; outline: none;
}
.mem textarea:focus { background: var(--surface-2); }
.mem.saved textarea { color: var(--text-2); }
.mem-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 2px; }

/* ---------- 更新按钮 ---------- */
.version-box { display: inline-flex; align-items: center; gap: 6px; }
.update-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 11px;
}
.update-btn svg { width: 11px; height: 11px; }
.update-btn:hover { border-color: var(--accent); color: var(--accent); }
.update-btn.available { border-color: var(--accent); background: var(--accent); color: #fff; }
.update-btn.busy svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 直接输入原文 ---------- */
.composer { flex: none; margin: 0 14px 10px; padding: 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.composer[hidden] { display: none; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  display: block; width: 100%; min-height: 60px; resize: none; border: none; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.55; padding: 2px 4px;
}
.composer-foot { display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.composer-foot .muted { flex: 1; }
.primary.small { height: 28px; padding: 0 12px; font-size: 12.5px; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
