/* 聊天页：模型菜单、模型详情、消息、Markdown、代码高亮、输入框 */
/* 模型切换 */
.model-picker { position: relative; min-width: 0; }
.model-btn {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 7px; border-radius: 10px;
  border: 0; background: transparent; max-width: 100%; font-weight: 600;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--hover); }
.model-btn > svg { color: var(--faint); transition: transform .2s; }
.model-btn[aria-expanded="true"] > svg { transform: rotate(180deg); }
.sheet-bg, .sheet-title { display: none; }
.model-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .prov { color: var(--faint); font-weight: 400; font-size: 13px; white-space: nowrap; }
.model-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.model-menu .grp { font-size: 12px; color: var(--faint); font-weight: 600; padding: 10px 10px 4px; }
.model-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px;
  border: 0; background: transparent; text-align: left;
}
.model-opt:hover { background: var(--hover); }
.model-opt .n { flex: 1; min-width: 0; }
.model-opt .n div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-opt .n small {
  color: var(--faint); font-size: 12px; line-height: 1.45; margin-top: 1px; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.model-opt.sel { background: var(--accent-soft); }
.model-row { display: flex; align-items: center; border-radius: 9px; }
.model-row .model-opt { flex: 1; min-width: 0; }
.model-row.sel { background: var(--accent-soft); }
.model-row.sel .model-opt:hover { background: transparent; }
.model-row.nochat .model-opt { opacity: .55; }
.info-btn {
  width: 34px; height: 34px; margin-right: 4px; border-radius: 50%; border: 0; background: transparent; color: var(--faint);
  display: grid; place-items: center; flex-shrink: 0;
}
.info-btn:hover { background: var(--hover); color: var(--accent); }
.tags { display: inline-flex; gap: 4px; vertical-align: 1px; margin-left: 2px; flex-wrap: wrap; }
.tag { font-size: 10.5px; line-height: 1; padding: 3px 6px; border-radius: 6px; background: var(--hover); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag.warn { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tags.big { margin: 0; }
.tags.big .tag { font-size: 12px; padding: 4px 9px; }

/* 模型详情弹窗 */
.info-head { display: flex; align-items: center; gap: 10px; }
.info-head .avatar { width: 38px; height: 38px; border-radius: 11px; font-size: 16px; }
.info-desc { font-size: 16px; font-weight: 600; line-height: 1.5; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.info-desc.warn { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.info-lines { display: grid; gap: 10px; }
.info-line { display: grid; grid-template-columns: 76px 1fr; gap: 10px; font-size: 14px; line-height: 1.6; }
.info-line b { color: var(--muted); font-weight: 600; }
.info-line:not(:has(b)) { grid-template-columns: 1fr; }
.info-caps { display: flex; flex-wrap: wrap; gap: 6px; }
.cap { font-size: 12.5px; padding: 4px 10px; border-radius: 99px; background: var(--hover); color: var(--faint); }
.cap.yes { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok); }
.info-edit { display: grid; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border); }
.model-opt .check { color: var(--accent); }
.model-menu .none { padding: 14px; color: var(--muted); font-size: 14px; }

/* 消息区 */
.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.thread-inner { max-width: 820px; margin: 0 auto; padding: 8px 20px 24px; }
.hero-logo {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow-sm);
}
.hero-logo img { width: 38px; height: 38px; }
/* 欢迎页：logo 外圈旋转的渐变光环 + 背后柔和的光晕，标题渐变色 */
.welcome .hero-logo { position: relative; }
.welcome .hero-logo::after {
  content: ""; position: absolute; inset: -5px; border-radius: 24px; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--spin, 0deg), #ff7a2f, #ff4f81, #8b5cf6, #22d3ee, #ff7a2f);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .85; animation: ring-spin 6s linear infinite;
}
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes ring-spin { to { --spin: 360deg; } }
.welcome { position: relative; isolation: isolate; }
.welcome::before {
  content: ""; position: absolute; left: 50%; top: 42%; width: min(620px, 92vw); height: 360px; transform: translate(-50%, -50%); z-index: -1;
  background: radial-gradient(closest-side, rgba(255, 122, 47, .16), transparent), radial-gradient(closest-side at 70% 60%, rgba(139, 92, 246, .14), transparent);
  filter: blur(20px); pointer-events: none;
}
.welcome .grad {
  background: linear-gradient(100deg, #ff7a2f, #ff4f81 50%, #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.welcome {
  min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 24px 4px; color: var(--muted); animation: rise .4s ease both;
}
.welcome .hero-logo { margin-bottom: 8px; }
.welcome h1 { margin: 0; color: var(--text); font-size: 26px; font-weight: 700; letter-spacing: .3px; }
.welcome p { margin: 0; font-size: 14px; }
.welcome p b { color: var(--text); font-weight: 600; }
.suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; width: min(560px, 100%); }
.suggest.one { display: flex; justify-content: center; }
.sg {
  display: grid; gap: 3px; text-align: left; padding: 13px 14px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: transform .15s, border-color .15s, background .15s;
}
.sg b { font-size: 14px; color: var(--text); font-weight: 600; }
.sg span { font-size: 13px; color: var(--faint); line-height: 1.45; }
.sg:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 10px 28px -12px color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-1px); }
.sg:active { transform: scale(.97); background: var(--hover); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.msg { margin: 20px 0; animation: rise .25s ease both; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); padding: 10px 15px; border-radius: 20px 20px 6px 20px;
  max-width: min(85%, 640px); white-space: pre-wrap; word-break: break-word;
}
.msg.assistant .who, .cmp-col .who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.msg.assistant .who .avatar, .cmp-col .who .avatar { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
.msg .actions { display: flex; gap: 2px; margin-top: 4px; color: var(--faint); align-items: center; font-size: 12px; }
.msg .actions .icon-btn { width: 30px; height: 30px; }
.msg .actions .meta { margin-left: 6px; }
.msg.user .actions { justify-content: flex-end; }
.msg-wrap { display: flex; flex-direction: column; align-items: flex-end; width: 100%; }
.err-box { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: 14px; word-break: break-word; }
.err-box.soft { background: var(--hover); color: var(--muted); }

details.reasoning { margin: 0 0 10px; border-left: 2px solid var(--border); padding-left: 12px; color: var(--muted); font-size: 14px; }
details.reasoning summary { cursor: pointer; user-select: none; font-size: 13px; color: var(--faint); list-style: none; }
details.reasoning summary::-webkit-details-marker { display: none; }
details.reasoning summary::before { content: "▸ "; }
details.reasoning[open] summary::before { content: "▾ "; }
details.reasoning .r-body { white-space: pre-wrap; margin-top: 6px; }

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Markdown */
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .table-wrap, .md .code { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md li.task { list-style: none; margin-left: -1.3em; }
.md blockquote { border-left: 3px solid var(--border); padding: 2px 0 2px 14px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.md .code { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.md .code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--faint); border-bottom: 1px solid var(--border); }
.md .code-head button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.md .code-head button:hover { background: var(--hover); }
.md pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
.md pre code { background: none; padding: 0; font-size: inherit; }
/* 代码高亮 */
.hl-c { color: var(--hl-comment); font-style: italic; }
.hl-s { color: var(--hl-string); }
.hl-n { color: var(--hl-number); }
.hl-k { color: var(--hl-keyword); font-weight: 600; }
.hl-f { color: var(--hl-func); }
.hl-t { color: var(--hl-type); }
.hl-a { color: var(--hl-attr); }
.hl-v { color: var(--hl-var); }
.hl-p { color: var(--hl-meta); }
.hl-ins { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); display: inline-block; width: 100%; }
.hl-del { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); display: inline-block; width: 100%; }
.md .table-wrap { overflow-x: auto; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--hover); }

/* 输入框 */
.composer-wrap { padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); position: relative; }
.composer-wrap::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 24px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg));
}
.composer {
  max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 26px; padding: 8px; display: grid; gap: 6px;
  box-shadow: var(--shadow-sm); transition: border-color .2s, box-shadow .2s;
}
.composer-row { display: flex; gap: 6px; align-items: flex-end; }
.composer.drag { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.attach-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; flex-shrink: 0;
}
.attach-btn:hover { background: var(--hover); color: var(--text); }
.attach-btn[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { .welcome .hero-logo::after { animation: none; } }
