/* Share · ChatGPT 对话分享 — 主题与布局 */

/* ---------- 主题变量 ---------- */
html[data-theme="gradient"] {
  --bg: #f7faf8; --fg: #23312b; --muted: #68796f;
  --card: rgba(255,255,255,.78); --card-border: rgba(35,49,43,.09);
  --bar-bg: rgba(247,250,248,.72);
  --accent: #177a53; --accent-fg: #ffffff; --accent-weak: rgba(23,122,83,.10);
  --user-bubble: #def0e6; --assistant-bubble: rgba(255,255,255,.94);
  --code-bg: rgba(35,49,43,.06); --danger: #b3392f;
  color-scheme: light;
}
html[data-theme="black"] {
  --bg: #000000; --fg: #e8eae9; --muted: #9aa39f;
  --card: #101112; --card-border: #26282a;
  --bar-bg: rgba(0,0,0,.82);
  --accent: #37c47f; --accent-fg: #03130b; --accent-weak: rgba(55,196,127,.14);
  --user-bubble: #10331f; --assistant-bubble: #141517;
  --code-bg: #0b0c0d; --danger: #e0655a;
  color-scheme: dark;
}
html[data-theme="white"] {
  --bg: #ffffff; --fg: #1f2937; --muted: #6b7280;
  --card: #ffffff; --card-border: #e5e7eb;
  --bar-bg: rgba(255,255,255,.85);
  --accent: #15803d; --accent-fg: #ffffff; --accent-weak: rgba(21,128,61,.08);
  --user-bubble: #e7f4ec; --assistant-bubble: #f9fafb;
  --code-bg: #f3f4f6; --danger: #b3392f;
  color-scheme: light;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px; line-height: 1.6;
  color: var(--fg); background: var(--bg);
  transition: background .35s ease, color .35s ease;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.35; }
.hidden { display: none !important; }

/* ---------- 渐变模糊背景 ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.bg i:nth-child(1) { width: 46vw; height: 46vw; min-width: 320px; min-height: 320px; background: #a8e6cf; top: -12vh; left: -10vw; }
.bg i:nth-child(2) { width: 40vw; height: 40vw; min-width: 280px; min-height: 280px; background: #ffd9bd; bottom: -14vh; right: -8vw; }
.bg i:nth-child(3) { width: 36vw; height: 36vw; min-width: 250px; min-height: 250px; background: #b9dcff; top: 32vh; right: 16vw; }
html:not([data-theme="gradient"]) .bg { display: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--bar-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}
.logo { font-weight: 800; font-size: 17px; text-decoration: none; color: var(--accent); letter-spacing: .5px; }
.nav { display: flex; gap: 4px; }
.nav-link {
  text-decoration: none; color: var(--muted); font-size: 14px;
  padding: 6px 12px; border-radius: 999px; transition: .15s;
}
.nav-link:hover { color: var(--accent); }
.nav-link.on { color: var(--accent); background: var(--accent-weak); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 13px; padding: 0 2px; }

/* ---------- 布局 ---------- */
.container { max-width: 900px; margin: 0 auto; padding: 0 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-sub { color: var(--muted); font-size: 13px; margin: -10px 0 16px; }
.stack { display: grid; gap: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 18px 20px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
html[data-theme="black"] .card, html[data-theme="white"] .card { backdrop-filter: none; -webkit-backdrop-filter: none; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.loading { text-align: center; color: var(--muted); padding: 32px; }

.conv-card { display: block; text-decoration: none; color: inherit; transition: .15s; }
.conv-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.conv-title { font-weight: 600; font-size: 16px; }
.conv-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.conv-preview { margin-top: 8px; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chip { border: 1px solid var(--card-border); border-radius: 999px; padding: 1px 10px; font-size: 12px; color: var(--muted); }
.chip.pub { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.person-card { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; transition: .15s; }
.person-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 19px; color: #1c3529;
}
.person-name { font-weight: 600; }
.person-sub { color: var(--muted); font-size: 13px; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  border: 1px solid var(--card-border); background: var(--card); color: var(--fg);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  transition: .15s; font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-fg); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--card-border); background: var(--card); color: var(--fg);
  font-size: 14px; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

.paste-box { display: grid; gap: 8px; }
.paste-area {
  width: 100%; min-height: 220px; resize: vertical;
  font-family: Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.6;
  padding: 14px; border-radius: 12px; border: 1.5px dashed var(--card-border);
  background: var(--card); color: var(--fg);
}
.paste-area:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; min-height: 18px; }
.hint.err { color: var(--danger); }

/* ---------- 登录 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 390px; }
.brand { margin: 0; text-align: center; font-size: 34px; letter-spacing: 1px; color: var(--accent); }
.sub { text-align: center; color: var(--muted); margin: 6px 0 18px; font-size: 14px; }
.tabs { display: flex; border: 1px solid var(--card-border); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.tab { flex: 1; padding: 9px; background: transparent; border: 0; cursor: pointer; color: var(--muted); font-size: 14px; font-family: inherit; }
.tab.on { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.form { display: grid; gap: 10px; }
.form-err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 聊天气泡 ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: min(86%, 720px); padding: 12px 16px 13px;
  border-radius: 16px; border: 1px solid var(--card-border);
}
.bubble.user { background: var(--user-bubble); border-bottom-right-radius: 5px; }
.bubble.assistant { background: var(--assistant-bubble); border-bottom-left-radius: 5px; }
.bubble .role { font-size: 11px; color: var(--muted); margin-bottom: 4px; letter-spacing: .5px; font-weight: 600; }
.bubble.is-pub { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-weak); }
.bubble .chips { margin-bottom: 6px; }

/* 多选 */
.msg-select { display: flex; gap: 10px; align-items: flex-start; width: 100%; cursor: pointer; border-radius: 16px; }
.msg-select .sel-box { margin-top: 14px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); cursor: pointer; }
.msg-select.checked .bubble { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 底部操作条 */
.action-bar {
  position: sticky; bottom: 14px; z-index: 10; margin-top: 18px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 10px 14px;
  box-shadow: 0 10px 32px rgba(0,0,0,.14);
}
html[data-theme="black"] .action-bar, html[data-theme="white"] .action-bar { backdrop-filter: none; }
.bar-count { color: var(--muted); font-size: 14px; margin-right: auto; }

.banner {
  margin-top: 16px; padding: 10px 16px; border-radius: 12px; font-size: 13px;
  background: var(--accent-weak); border: 1px solid var(--accent); color: var(--accent);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

/* ---------- Markdown 渲染 ---------- */
.md { font-size: 15px; line-height: 1.75; overflow-wrap: break-word; }
.md > :first-child, .md :first-child { margin-top: 0; }
.md > :last-child, .md :last-child { margin-bottom: 0; }
.md p { margin: 8px 0; white-space: pre-wrap; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 16px 0 8px; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.1em; }
.md ul, .md ol { margin: 8px 0; padding-left: 1.6em; }
.md li { margin: 3px 0; }
.md pre {
  background: var(--code-bg); border: 1px solid var(--card-border);
  padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: 10px 0;
}
.md code { font-family: Consolas, "Courier New", monospace; font-size: .9em; }
.md :not(pre) > code { background: var(--code-bg); padding: .12em .4em; border-radius: 5px; }
.md table { border-collapse: collapse; margin: 10px 0; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--card-border); padding: 6px 12px; }
.md th { background: var(--accent-weak); }
.md blockquote {
  margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-weak); border-radius: 0 8px 8px 0;
}
.md blockquote p { margin: 6px 0; }
.md img { max-width: 100%; border-radius: 8px; }
.md hr { border: 0; border-top: 1px solid var(--card-border); margin: 14px 0; }
.md a { word-break: break-all; }
.img-group {
  margin: 10px 0; padding: 14px; border-radius: 10px; font-size: 13px; color: var(--muted);
  border: 1.5px dashed var(--card-border); text-align: center; background: var(--code-bg);
}
.math-block { display: block; overflow-x: auto; text-align: center; margin: 8px 0; }
.math-inline { white-space: nowrap; }
.md .katex { font-size: 1.05em; }
.md .katex-display { margin: 0; }

/* ---------- 预览 ---------- */
.preview { margin-top: 14px; }
.preview-label { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.preview .chat { gap: 10px; margin-top: 0; }
.preview .bubble { padding: 9px 13px; font-size: 14px; }

/* ---------- 提示 ---------- */
#toast-root { position: fixed; top: 18px; left: 0; right: 0; display: flex; justify-content: center; z-index: 99; pointer-events: none; }
.toast {
  opacity: 0; transform: translateY(-8px); transition: .25s ease;
  background: #22312b; color: #fff; padding: 9px 20px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; max-width: 86vw;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .nav { order: 3; width: 100%; justify-content: space-around; }
  .top-actions { margin-left: auto; }
  .container { padding: 0 12px 50px; }
  .bubble { max-width: 94%; }
  .page-head h2 { font-size: 19px; }
  .md { font-size: 14.5px; }
}
