﻿/* 玖通AI工作台 —— 宣纸 / 朱砂视觉（对齐桌面参考项目） */
:root {
  --ink: #1a1612;
  --ink-soft: #3b342c;
  --paper: #f6f1e7;
  --paper-2: #efe7d8;
  --card: #fffdf8;
  --line: #d8cebe;
  --cinnabar: #b74121;
  --ok: #2f6f4e;
  --gold: #b8893a;
  --danger: #9d2b1f;
  --shadow: 0 18px 40px rgba(26, 22, 18, 0.08);
  --sidebar: 288px;
  --sidebar-rail: 64px;
  --conversation-width: 960px;
  --scroll-size: 8px;
  --scroll-thumb: rgba(26, 22, 18, 0.22);
  --scroll-thumb-hover: rgba(26, 22, 18, 0.4);
  font-family: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong",
    "SimSun", Palatino, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.active-skill-status { width: 100%; max-width: var(--conversation-width); margin: 0 auto 6px; }
.active-skill-status:empty { display: none; }
.active-skill-status .case-actions { justify-content: flex-end; gap: 8px; padding: 0 12px; font-size: 12px; }
.active-skill-status .case-actions strong { flex: initial; font-weight: 400; color: var(--ink-soft); }
.active-skill-status .case-actions button { padding: 3px 8px; font-size: 12px; }
.html-preview { margin: 12px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.html-preview-title { padding: 10px 14px; font-size: 13px; color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.html-preview iframe { display: block; width: 100%; height: min(720px, 75vh); min-height: 340px; border: 0; background: white; }
.html-preview details { padding: 8px 14px; font-size: 13px; }
.html-preview details pre { max-height: 320px; overflow: auto; }
.html-preview-loading { min-height: 180px; padding: 28px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--ink-soft); background: var(--paper); }
.html-preview-loading strong { font-size: 14px; font-weight: 500; }
.html-preview-loading > span:last-child { font-size: 12px; opacity: .75; }
.html-preview-spinner { width: 24px; height: 24px; margin-bottom: 4px; border: 2px solid var(--line); border-top-color: var(--cinnabar); border-radius: 50%; animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .html-preview-spinner { animation: none; } }
.skill-session { width: 100%; max-width: var(--conversation-width); margin: 16px auto; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); }
.skill-session p { line-height: 1.7; color: var(--ink-soft); }
.skill-session fieldset { margin: 12px 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; max-height: 300px; overflow-y: auto; }
.case-option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px; line-height: 1.6; overflow-wrap: anywhere; cursor: pointer; }
.case-option input { flex: 0 0 auto; margin-top: 6px; accent-color: var(--cinnabar); }
.case-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.case-actions strong { flex: 1; }
.case-actions button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.case-actions .case-confirm { background: var(--cinnabar); color: white; border-color: var(--cinnabar); }
.case-actions button:disabled { opacity: .5; cursor: wait; }
@media (prefers-color-scheme: dark) {
  .skill-session { --card: #242424; --ink: #f0ede8; --ink-soft: #cbc6bf; --line: #4b4640; }
}

/* ---------- 登录 ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 10% -10%, #f3d8cf 0%, transparent 50%),
    radial-gradient(900px 400px at 110% 10%, #dce6d8 0%, transparent 46%),
    var(--paper);
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 30px; font-weight: 600; }
.login-card p { margin: 0 0 22px; opacity: 0.65; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.field input:focus { border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(183, 65, 33, 0.12); }
.captcha-row { display: flex; gap: 10px; }
.captcha-row input { flex: 1; min-width: 0; }
.captcha-img {
  height: 44px;
  width: 132px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  object-fit: cover;
  background: #fff;
  flex: 0 0 auto;
}
.login-card .btn { width: 100%; }
.error { color: var(--danger); font-size: 13px; margin: 0 0 10px; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 15px;
  background: var(--cinnabar);
  color: #fffdf8;
  font-size: 14px;
}
.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(239, 231, 216, 0.2);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 壳 ---------- */
.app-shell {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  transition: grid-template-columns 0.2s ease;
}
.sidebar {
  position: relative;
  background: var(--ink);
  color: #efe7d8;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
  padding: 18px 14px;
  font-size: 14px;
  transition: padding 0.2s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0 16px;
}
.brand-logo {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  overflow: visible;
}
.brand-logo .logo-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  mix-blend-mode: screen;
}
.brand-logo .logo-expand {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  background: #2a241c;
  color: #efe7d8;
  border-radius: 50%;
}
.brand-logo .logo-expand svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-text { flex: 1; min-width: 0; }
.brand-text b { display: block; font-size: 19px; letter-spacing: 0.06em; line-height: 1.15; white-space: nowrap; }
.brand-text span { display: block; font-size: 12px; opacity: 0.62; white-space: nowrap; }
.sidebar-fold { margin-left: auto; }
.btn.new-chat { width: 100%; }

.icon-btn {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: inherit;
  opacity: 0;
  pointer-events: none;
}
.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.conv-item:hover .icon-btn,
.icon-btn.sidebar-fold {
  opacity: 0.7;
  pointer-events: auto;
}
.icon-btn:hover { opacity: 1; background: rgba(255,253,248,0.1); }
.icon-btn.danger:hover { color: #f3d8cf; background: rgba(183,65,33,0.35); }
.icon-btn.sidebar-fold { opacity: 0.7; pointer-events: auto; }

.conv-list {
  flex: 1;
  overflow: auto;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(239, 231, 216, 0.28) transparent;
}
.conv-item {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0 6px 0 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  cursor: pointer;
}
.conv-item.active, .conv-item:hover { background: rgba(255,253,248,0.08); }
.ghost-link {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 8px 8px 8px 10px;
  flex: 1;
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.conv-title {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  width: 100%;
  min-width: 0;
}
.conv-title-inner {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.conv-title.scrolling .conv-title-inner {
  max-width: none;
  text-overflow: clip;
  animation: title-scroll 3.6s linear infinite alternate;
}
@keyframes title-scroll {
  0%, 15% { transform: translateX(0); }
  85%, 100% { transform: translateX(var(--scroll, 0px)); }
}

.recent-wrap {
  display: none;
  position: relative;
  margin-top: 10px;
}
.recent-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(239, 231, 216, 0.28);
  border-radius: 11px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 253, 248, 0.08);
  color: #efe7d8;
}
.recent-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.recent-btn:hover,
.recent-wrap:hover .recent-btn {
  background: rgba(255, 253, 248, 0.16);
  border-color: rgba(239, 231, 216, 0.48);
}
.recent-pop {
  position: absolute;
  left: 100%;
  top: -8px;
  z-index: 30;
  width: 268px;
  max-width: min(268px, 72vw);
  max-height: min(68vh, 520px);
  display: flex;
  flex-direction: column;
  margin-left: 8px;
  padding: 10px 8px 8px;
  border: 1px solid rgba(239, 231, 216, 0.14);
  border-radius: 16px;
  background: #211c17;
  color: #efe7d8;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.recent-pop::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 8px;
  width: 12px;
  height: 44px;
}
.recent-pop header {
  flex: 0 0 auto;
  padding: 4px 10px 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0.55;
}
.recent-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.recent-list button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-list button:hover,
.recent-list button.active { background: rgba(255, 253, 248, 0.08); }
.recent-list p {
  margin: 0;
  padding: 12px 8px;
  font-size: 13px;
  opacity: 0.5;
  text-align: center;
}

.userbox {
  position: relative;
  z-index: 21;
  border-top: 1px solid rgba(239,231,216,0.12);
  padding: 10px 8px 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 12px;
  cursor: pointer;
}
.userbox:hover { background: rgba(255,253,248,0.08); }
.userbox.open { background: #2c261f; }
.user-meta { flex: 1; min-width: 0; }
.sidebar-foot {
  margin-top: auto;
}
.app-version {
  margin: 2px 8px 0;
  padding: 0;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  opacity: 0.42;
  color: #efe7d8;
  font-variant-numeric: tabular-nums;
  user-select: text;
  cursor: default;
}
.userbox strong { display: block; font-size: 14px; }
.userbox em,
.user-pop em {
  display: block;
  font-style: normal;
  opacity: 0.55;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  background: #efe7d8;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
.user-pop {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: calc(100% + 10px);
  z-index: 30;
  padding: 10px 8px 8px;
  border: 1px solid rgba(239, 231, 216, 0.32);
  border-radius: 16px;
  background: #2c261f;
  color: #efe7d8;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.28);
}
.user-pop header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(239, 231, 216, 0.12);
}
.user-pop header strong { font-size: 14px; }
.user-pop button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 14px;
}
.user-pop button:hover { background: rgba(255, 253, 248, 0.08); }
.user-pop button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}

.settings-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(26, 22, 18, 0.35);
}
.settings-dialog {
  width: min(420px, 100%);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
}
.settings-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.settings-dialog h2 { margin: 0; font-size: 20px; font-weight: 600; }
.settings-dialog .icon-btn {
  opacity: 0.65;
  pointer-events: auto;
  color: var(--ink);
}
.settings-dialog dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-dialog dl > div {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper);
}
.settings-dialog dt {
  font-size: 12px;
  opacity: 0.55;
  margin-bottom: 4px;
}
.settings-dialog dd { margin: 0; font-size: 15px; word-break: break-all; }

.main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: none;
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
}
.topbar .btn.ghost {
  color: var(--ink);
  border-color: var(--line);
}

.chat-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  --composer-space: 152px;
}
.chat-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.chat-stage .chat-pane { padding-bottom: var(--composer-space); }
.chat { padding: 28px 8vw 20px; }

.empty {
  max-width: 760px;
  margin: 8vh auto 0;
  text-align: left;
}
.empty h1 { font-weight: 600; font-size: 36px; margin: 0 0 12px; }
.empty p { opacity: 0.7; margin: 0 0 22px; line-height: 1.65; }
.prompts { display: grid; gap: 10px; }
.prompts button {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--ink);
}
.prompts button:hover { background: var(--paper-2); }

.bubble {
  max-width: var(--conversation-width);
  margin: 0 auto 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.bubble.user { align-items: flex-end; }
.bubble.assistant { padding-right: 0; }
.bubble.assistant .bubble-main { width: 100%; }
.bubble.assistant .body.markdown { width: 100%; padding: 16px 20px; }
.bubble.assistant .copy-btn { left: auto; right: 8px; bottom: 10px; }
.bubble-main {
  position: relative;
  width: fit-content;
  max-width: 100%;
}
.bubble .body {
  width: fit-content;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
}
.bubble.user .body { background: var(--paper-2); }
.bubble.assistant.is-error .body,
.bubble .body.is-error {
  color: var(--danger);
  background: #f8eee8;
  border-color: rgba(157, 43, 31, 0.22);
}
.bubble.assistant .body.markdown { white-space: normal; }
.bubble .md > :first-child { margin-top: 0; }
.bubble .md > :last-child { margin-bottom: 0; }
.bubble .md p { margin: 0 0 0.65em; }
.bubble .md p:last-child { margin-bottom: 0; }
.bubble .md h1, .bubble .md h2, .bubble .md h3, .bubble .md h4 {
  margin: 0.9em 0 0.4em;
  line-height: 1.35;
  font-weight: 650;
}
.bubble .md h1 { font-size: 1.35em; }
.bubble .md h2 { font-size: 1.2em; }
.bubble .md h3 { font-size: 1.08em; }
.bubble .md ul, .bubble .md ol { margin: 0 0 0.65em; padding-left: 1.4em; }
.bubble .md li { margin: 0.2em 0; }
.bubble .md blockquote {
  margin: 0 0 0.65em;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--gold);
  color: var(--ink-soft);
}
.bubble .md hr { border: 0; border-top: 1px solid var(--line); margin: 0.9em 0; }
.bubble .md a { color: var(--cinnabar); text-decoration: underline; }
.bubble .md code {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--paper-2);
  border-radius: 6px;
  padding: 0.12em 0.4em;
}
.bubble .md pre {
  margin: 0 0 0.75em;
  padding: 12px 14px;
  overflow-x: auto;
  background: #211c17;
  border: 1px solid #3b342c;
  border-radius: 12px;
  scrollbar-width: thin;
}
.bubble .md pre code,
.bubble .md pre .hljs {
  padding: 0;
  background: none;
  border-radius: 0;
  font-size: 0.84em;
  line-height: 1.55;
  white-space: pre;
  color: #efe7d8;
}
.bubble .md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 0.75em;
  font-size: 0.92em;
}
.bubble .md th, .bubble .md td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.bubble .md th { background: var(--paper-2); font-weight: 650; }
.bubble .md img { max-width: 100%; border-radius: 10px; }
.bubble.assistant.streaming .body::after,
.bubble.assistant.streaming .md *::after {
  content: none;
}
.stream-caret {
  display: inline;
  margin-left: 2px;
  white-space: nowrap;
  vertical-align: -0.05em;
  animation: caret 0.9s step-end infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.copy-btn {
  position: absolute;
  left: calc(100% + 6px);
  bottom: 4px;
  z-index: 2;
  width: 28px;
  height: 28px;
  margin: 0;
  border: 0;
  border-radius: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-soft);
  opacity: 0;
  pointer-events: none;
  text-decoration: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.copy-btn::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 0;
  width: 10px;
  height: 100%;
}
.copy-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bubble.assistant:hover .copy-btn,
.bubble.assistant:focus-within .copy-btn {
  opacity: 0.55;
  pointer-events: auto;
}
.bubble.assistant .copy-btn:hover,
.bubble.assistant .copy-btn:focus-visible {
  opacity: 1;
  color: var(--ink);
  background: rgba(26, 22, 18, 0.06);
}
.copy-btn.is-copied {
  opacity: 1;
  color: var(--ok);
  pointer-events: auto;
}
@media (hover: none) {
  .copy-btn {
    opacity: 0.5;
    pointer-events: auto;
  }
}
@media (max-width: 860px) {
  .bubble.assistant { padding-right: 0; }
  .copy-btn {
    left: auto;
    right: 6px;
    bottom: auto;
    top: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
}

.message-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 4px 4px 0; padding-top: 0;
}
.bubble.assistant .message-actions button {
  position: static; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; width: auto; height: 32px; padding: 5px 10px; margin: 0;
  border: 0; border-radius: 6px; background: transparent; box-shadow: none;
  color: var(--ink-soft); font-size: 12px; opacity: 1; pointer-events: auto;
}
.message-actions .copy-btn::before { display: none; }
.bubble.assistant:hover .message-actions .copy-btn,
.bubble.assistant:focus-within .message-actions .copy-btn { opacity: 1; }
.bubble.assistant .message-actions button:hover { background: var(--paper-2); color: var(--ink); }
.bubble.assistant .message-actions .is-copied { color: var(--ok); }

.think-fold {
  max-width: var(--conversation-width);
  margin: 0 auto 10px;
}
.think-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.04em;
  opacity: 0.72;
  cursor: pointer;
}
.think-toggle:focus-visible { outline: 2px solid var(--line-strong, #bbb); outline-offset: 2px; border-radius: 4px; }
.think-fold.live .think-toggle { opacity: 0.88; }
.think-fold-mark {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 0.15s ease;
}
.think-fold.open .think-fold-mark { transform: rotate(90deg); }
.think-body {
  margin-top: 6px;
  padding: 10px 12px;
  border-left: 2px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}
.think-dots::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: think-dots 1.2s steps(4, end) infinite;
}
@keyframes think-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.tool-fold {
  max-width: var(--conversation-width);
  margin: 0 auto 8px;
}
.tool-fold summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  opacity: 0.72;
  user-select: none;
}
.tool-fold summary::-webkit-details-marker { display: none; }
.tool-fold-mark {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 0.15s ease;
}
.tool-fold[open] .tool-fold-mark { transform: rotate(90deg); }
.tool-fold-list {
  margin: 8px 0 0;
  padding: 8px 12px;
  list-style: none;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,253,248,0.55);
  font-size: 13px;
}
.tool-fold-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.tool-fold pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: #211c17;
  color: #efe7d8;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 2px;
  background: var(--gold);
  flex: 0 0 auto;
}
.status-dot.ok { background: var(--ok); }
.status-dot.fail { background: var(--danger); }
.status-dot.wait { background: var(--cinnabar); }
.hint { font-size: 12px; opacity: 0.5; }

.img-bubble { gap: 0; width: 100%; }
.img-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}
.img-card {
  position: relative;
  width: fit-content;
  max-width: min(560px, 100%);
  border-radius: 18px;
  overflow: hidden;
  background: #e9e1d2;
  box-shadow: 0 10px 28px rgba(26, 22, 18, 0.1);
  cursor: pointer;
}
.img-card.is-loading,
.img-card.is-error {
  width: min(560px, 100%);
  min-width: min(240px, 100%);
  cursor: default;
}
.img-card .gen-img {
  display: block;
  max-width: min(560px, 100%);
  max-height: min(72vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.28s ease;
}
.img-card .gen-img.is-ready { opacity: 1; }
.img-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.img-card:hover .img-actions,
.img-card:focus-within .img-actions {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
@media (hover: none) {
  .img-actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}
.img-dl {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(26, 22, 18, 0.72);
  color: #fffdf8;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 16px rgba(26, 22, 18, 0.22);
}
.img-dl:hover { background: rgba(26, 22, 18, 0.88); }
.img-dl svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.img-skel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  aspect-ratio: 1;
  overflow: hidden;
  background:
    linear-gradient(165deg, #f6eee3 0%, #eadfce 52%, #e3d6c3 100%);
  color: var(--ink-soft);
}
.img-skel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 42%, rgba(255, 253, 248, 0.35), transparent 72%);
  animation: img-breathe 3.6s ease-in-out infinite;
}
.img-skel::after {
  content: "";
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: 0;
  width: 42%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 252, 246, 0.08) 28%,
    rgba(255, 252, 246, 0.42) 50%,
    rgba(255, 252, 246, 0.08) 72%,
    transparent 100%
  );
  filter: blur(6px);
  animation: img-shimmer 2.8s cubic-bezier(0.45, 0, 0.2, 1) infinite;
  pointer-events: none;
}
.img-card.is-error .img-skel::before,
.img-card.is-error .img-skel::after {
  animation: none;
  opacity: 0;
}
.img-skel-spin,
.img-skel-text,
.img-error-msg { position: relative; z-index: 1; }
.img-skel-spin {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(26, 22, 18, 0.1);
  border-top-color: var(--cinnabar);
  border-radius: 50%;
  animation: spin 1.15s linear infinite;
}
.img-skel-text {
  font-size: 13px;
  letter-spacing: 0.04em;
  opacity: 0.78;
}
.img-card.is-error .img-skel { background: #f3e6dc; }
.img-error-msg {
  max-width: 80%;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--danger);
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@keyframes img-shimmer {
  0% {
    transform: translateX(-130%) skewX(-12deg);
    opacity: 0;
  }
  18% { opacity: 1; }
  62% { opacity: 0.85; }
  78% {
    transform: translateX(280%) skewX(-12deg);
    opacity: 0;
  }
  100% {
    transform: translateX(280%) skewX(-12deg);
    opacity: 0;
  }
}
@keyframes img-breathe {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg) } }

.img-preview {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(26, 22, 18, 0.78);
  cursor: pointer;
}
.img-preview.hidden { display: none; }
.img-preview img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: min(1100px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  cursor: default;
}
.img-preview-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 253, 248, 0.22);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(26, 22, 18, 0.42);
  color: #fffdf8;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}
.img-preview-close:hover {
  background: rgba(26, 22, 18, 0.62);
  border-color: rgba(255, 253, 248, 0.38);
}
.img-preview-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  padding: 36px 8vw calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    rgba(246, 241, 231, 0) 0%,
    rgba(246, 241, 231, 0.55) 28%,
    var(--paper) 62%
  );
  pointer-events: none;
}
.composer-wrap > * { pointer-events: auto; }
.composer {
  max-width: var(--conversation-width);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 6px 6px 6px 8px;
  box-shadow: 0 12px 36px rgba(26, 22, 18, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  overflow: visible;
  position: relative;
}
.composer.tall {
  flex-direction: column;
  align-items: stretch;
  border-radius: 24px;
  padding: 12px 12px 8px;
  gap: 4px;
}
.composer textarea {
  display: block;
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  border: 0;
  resize: none;
  height: 36px;
  min-height: 36px;
  max-height: 160px;
  padding: 6px 4px;
  line-height: 24px;
  background: transparent;
  outline: none;
  overflow-y: hidden;
  color: var(--ink);
}
.composer.tall textarea {
  width: 100%;
  flex: none;
  max-height: 240px;
  padding: 2px 6px 6px;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.composer:not(.tall):not(.has-skill) .composer-bar { display: contents; }
.composer:not(.tall):not(.has-skill) .composer-attach { order: 1; align-self: center; }
.composer:not(.tall):not(.has-skill) textarea { order: 2; }
.composer:not(.tall):not(.has-skill) .send-btn { order: 3; align-self: center; }
.composer:not(.tall) .hint { display: none; }
.composer.has-skill,
.composer.tall {
  flex-direction: column;
  align-items: stretch;
  border-radius: 24px;
  padding: 12px 12px 8px;
  gap: 4px;
}
.composer.has-skill textarea,
.composer.tall textarea {
  width: 100%;
  flex: none;
  max-height: 240px;
  padding: 2px 6px 6px;
}
.composer.has-skill .composer-bar,
.composer.tall .composer-bar {
  display: flex;
  width: 100%;
  min-height: 34px;
}
.composer-bar .hint {
  flex: 1;
  display: flex;
  align-items: center;
  height: 34px;
  margin: 0;
  line-height: 1;
}
.composer-attach { position: relative; }
.plus-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-soft);
  transition: background-color 0.22s ease;
}
.plus-btn:hover, .plus-btn.open { background: var(--paper-2); }
.plus-icon {
  position: relative;
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
  transform: translateZ(0);
}
.plus-icon::before,
.plus-icon::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: currentColor;
  transform-origin: 50% 50%;
  will-change: transform;
  backface-visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.plus-icon::before { transform: rotate(90deg); }
.plus-icon::after { transform: rotate(0deg); }
.plus-btn.open .plus-icon::before { transform: rotate(135deg); }
.plus-btn.open .plus-icon::after { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) {
  .plus-icon::before,
  .plus-icon::after { transition: none; }
}
.plus-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.attach-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  width: min(380px, 78vw);
  padding: 6px 6px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 30;
}
.attach-pop-list {
  max-height: min(360px, 50vh);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.attach-pop button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: inherit;
}
.attach-pop button:hover,
.attach-pop button.active { background: var(--paper-2); }
.attach-pop button > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.attach-pop b {
  display: block;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attach-pop small {
  display: block;
  font-size: 12px;
  opacity: 0.5;
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attach-pop-empty {
  margin: 0;
  padding: 18px 12px;
  text-align: center;
  font-size: 13px;
  opacity: 0.55;
}
.attach-pop-search {
  display: block;
  margin: 4px 6px 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.attach-pop-search input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  padding: 8px 6px;
  color: var(--ink);
}
.attach-pop-search input::placeholder { color: var(--ink-soft); opacity: 0.55; }
.attach-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #efe8dc;
  color: var(--ink-soft);
  flex: 0 0 auto;
}
.attach-ico.image {
  background: #e7f3ff;
  color: #2f7de1;
}
.attach-ico.upload {
  background: #efe8dc;
  color: var(--ink-soft);
}
.attach-ico.tool {
  background: #efe7d8;
  color: var(--cinnabar);
}
.attach-ico svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer-skill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  padding: 6px 8px 4px 4px;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
.composer-skill-ico {
  width: 18px;
  height: 18px;
  flex: none;
  color: #3b6fd4;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 4px;
}
.composer-skill-ico svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer-skill-ico img {
  width: 18px;
  height: 18px;
  object-fit: cover;
  display: block;
}
.composer-skill-cat {
  flex: none;
  color: #3b6fd4;
  font-size: 14px;
  font-weight: 650;
}
.composer-skill-desc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--ink);
}
.composer-skill-x {
  margin-left: auto;
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f4efe6;
  color: #8a8074;
}
.composer-skill-x svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer-skill-x:hover { background: #efe6d8; color: var(--ink); }
.send-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--cinnabar);
  color: #fffdf8;
  flex: 0 0 auto;
}
.send-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.send-btn.busy {
  background: var(--ink);
}
.send-btn.busy svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: none;
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-foot {
  max-width: var(--conversation-width);
  margin: 10px auto 0;
  text-align: center;
  font-size: 12px;
  opacity: 0.5;
}

/* 侧栏「技能库」菜单项，视觉与 new-chat 呼应但作次级项 */
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(239, 231, 216, 0.28);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.08);
  color: #efe7d8;
  font-size: 14px;
  text-align: center;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(255, 253, 248, 0.16);
  border-color: rgba(239, 231, 216, 0.48);
  color: #fffdf8;
}
.nav-item svg {
  display: none;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 待发送附件缩略条：非 tall 态独占第一行，tall 态按 DOM 顺序天然整行 */
.attach-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 4px;
}
.composer:not(.tall) .attach-strip { order: 0; flex: 0 0 100%; }
.attach-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper-2);
  flex: 0 0 auto;
  cursor: pointer;
}
.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-thumb.is-loading {
  display: grid;
  place-items: center;
}
.attach-thumb.is-loading::after {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--cinnabar);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.attach-thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  line-height: 0;
  cursor: pointer;
}
.attach-thumb-del svg {
  width: 10px;
  height: 10px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .attach-thumb.is-loading::after { animation: none; }
}

/* 消息气泡内的图片缩略图与技能标签 */
.bubble-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.bubble-thumb {
  width: 120px;
  max-width: 60vw;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: block;
}
.bubble-thumb img { width: 100%; display: block; }
.msg-skill {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(420px, 100%);
  margin: 0 2px 8px;
  padding: 0 2px;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #3b6fd4;
}
.bubble.user .msg-skill { justify-content: flex-end; }
.msg-skill-ico {
  width: 16px;
  height: 16px;
  flex: none;
  display: grid;
  place-items: center;
}
.msg-skill-ico svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg-skill-ico img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}
.msg-skill-cat {
  flex: none;
  font-size: 13px;
  font-weight: 650;
}
.msg-skill-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink-soft);
}

/* 技能库覆盖层：盖在对话上方，不动 .main 的 flex 结构 */
.skill-lib {
  position: absolute;
  inset: 0;
  z-index: 7;
  background: var(--paper);
  overflow: auto;
  padding: 28px clamp(16px, 3vw, 32px) 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #2b241c;
}
.skill-lib-inner,
.skill-lib > .skill-lib-head,
.skill-lib > .skill-toolbar,
.skill-lib > .skill-grid,
.skill-lib > .skill-empty {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}
.skill-lib-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.skill-lib-intro h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.skill-lib-intro p {
  margin: 0;
  color: #7a7166;
  font-size: 13.5px;
  line-height: 1.7;
  max-width: 34em;
}
.skill-lib-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.skill-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(280px, 72vw);
  background: #fff;
  border: 1px solid #eadfd0;
  border-radius: 999px;
  padding: 0 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
.skill-search svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: #b3a89a;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.skill-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 0;
  outline: none;
  font-size: 13px;
  color: var(--ink);
}
.skill-search input::placeholder { color: #b3a89a; }
.skill-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.skill-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-filters button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  color: #8a8074;
  font-size: 13px;
}
.skill-filters button:hover { background: rgba(26, 22, 18, 0.05); color: #2b241c; }
.skill-filters button.active {
  background: #1f1a16;
  color: #fffdf8;
}
.skill-empty {
  grid-column: 1 / -1;
  color: #8a8074;
  margin: 36px 0;
  text-align: center;
}
.skill-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.skill-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 196px;
  padding: 18px 16px 14px;
  border: 1px solid #efe6d8;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(43, 36, 28, 0.04);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.skill-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(43, 36, 28, 0.08);
}
.skill-card-top {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.skill-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}
.skill-ico svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.skill-ico img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.skill-ico.peach { background: #fde8d8; color: #e06a2c; }
.skill-ico.lilac { background: #eee4fb; color: #7a5ad4; }
.skill-ico.sky { background: #ddeefb; color: #3b82c4; }
.skill-ico.moss { background: #dcefe4; color: #3d8f63; }
.skill-ico.mint { background: #d8f3ee; color: #2a9b8f; }
.skill-card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.skill-card > p {
  margin: 0 0 12px;
  color: #8a8074;
  font-size: 13px;
  line-height: 1.55;
  min-height: 40px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.skill-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.skill-tags span {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f4efe6;
  color: #8a8074;
}
.skill-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  min-height: 32px;
}
.skill-use {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 32px;
  line-height: 1;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: #e05a32;
  color: #fffdf8;
  font-size: 13px;
}
.skill-use:hover { filter: brightness(1.05); }
.skill-detail {
  width: min(460px, 100%);
  max-height: min(84vh, 720px);
  overflow: auto;
  background: #fff;
  color: #2b241c;
  border: 1px solid #eadfd0;
  border-radius: 20px;
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
.skill-detail header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.skill-detail h2 { margin: 0; font-size: 20px; font-weight: 700; }
.skill-detail p {
  margin: 0;
  line-height: 1.7;
  color: #5c5349;
  white-space: pre-wrap;
  word-break: break-word;
}
.skill-detail .icon-btn {
  opacity: 0.65;
  pointer-events: auto;
  color: var(--ink);
}
.skill-detail .btn {
  margin-top: 16px;
  background: #e05a32;
}
@media (max-width: 1180px) {
  .skill-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .skill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skill-lib { padding: 20px 16px 36px; }
}
@media (max-width: 560px) {
  .skill-grid { grid-template-columns: 1fr; }
}

@media (min-width: 861px) {
  .app-shell.collapsed { grid-template-columns: var(--sidebar-rail) 1fr; }
  .sidebar {
    overflow: visible;
    z-index: 8;
  }
  .user-pop {
    left: 100%;
    right: auto;
    bottom: 0;
    width: 252px;
    margin-left: 12px;
  }
  .user-pop::before {
    content: "";
    position: absolute;
    right: 100%;
    bottom: 0;
    width: 16px;
    height: 48px;
  }
  .sidebar.collapsed {
    padding: 18px 9px;
    align-items: center;
    overflow: visible;
    z-index: 8;
  }
  .sidebar.collapsed .recent-wrap { display: block; }
  .sidebar.collapsed .brand {
    width: 100%;
    padding: 5px 0 16px;
    justify-content: center;
  }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .sidebar-fold,
  .sidebar.collapsed .user-meta,
  .sidebar.collapsed .app-version,
  .sidebar.collapsed .new-chat span,
  .sidebar.collapsed .nav-item span { display: none; }
  .sidebar.collapsed .nav-item {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 11px;
  }
  .sidebar.collapsed .nav-item svg {
    display: block;
  }
  .sidebar.collapsed .conv-list {
    visibility: hidden;
    overflow: hidden;
    pointer-events: none;
  }
  .sidebar.collapsed .brand-logo:hover .logo-img { opacity: 0; }
  .sidebar.collapsed .brand-logo:hover .logo-expand { display: grid; }
  .sidebar.collapsed .new-chat {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 11px;
  }
  .sidebar.collapsed .new-chat::after { content: "+"; font-size: 20px; line-height: 1; }
  .sidebar.collapsed .userbox {
    margin-top: auto;
    border: 0;
    padding: 8px;
    justify-content: center;
    width: auto;
  }
  .sidebar.collapsed .user-pop {
    width: 240px;
    margin-left: 8px;
  }
}

.chat-pane,
.conv-list,
.composer textarea,
.recent-list,
.skill-lib,
.attach-pop-list {
  scrollbar-width: thin;
}
.chat-pane::-webkit-scrollbar,
.conv-list::-webkit-scrollbar,
.composer textarea::-webkit-scrollbar,
.recent-list::-webkit-scrollbar,
.skill-lib::-webkit-scrollbar,
.attach-pop-list::-webkit-scrollbar {
  width: var(--scroll-size);
  height: var(--scroll-size);
}
.chat-pane::-webkit-scrollbar-button,
.conv-list::-webkit-scrollbar-button,
.composer textarea::-webkit-scrollbar-button,
.recent-list::-webkit-scrollbar-button,
.skill-lib::-webkit-scrollbar-button,
.attach-pop-list::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
.chat-pane::-webkit-scrollbar-track,
.conv-list::-webkit-scrollbar-track,
.composer textarea::-webkit-scrollbar-track,
.recent-list::-webkit-scrollbar-track,
.skill-lib::-webkit-scrollbar-track,
.attach-pop-list::-webkit-scrollbar-track {
  background: transparent;
}
.chat-pane::-webkit-scrollbar-thumb,
.composer textarea::-webkit-scrollbar-thumb,
.skill-lib::-webkit-scrollbar-thumb,
.attach-pop-list::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.chat-pane::-webkit-scrollbar-thumb:hover,
.composer textarea::-webkit-scrollbar-thumb:hover,
.skill-lib::-webkit-scrollbar-thumb:hover,
.attach-pop-list::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.conv-list::-webkit-scrollbar-thumb,
.recent-list::-webkit-scrollbar-thumb {
  background: rgba(239, 231, 216, 0.28);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar-fold, .logo-expand { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 20;
  }
  .sidebar.open { transform: none; }
  .sidebar.open:has(.userbox.open)::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(10, 8, 6, 0.48);
    z-index: 20;
  }
  .backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26,22,18,.35);
    z-index: 15;
  }
  .topbar { display: flex; }
  .chat, .composer-wrap { padding-left: 16px; padding-right: 16px; }
  .empty h1 { font-size: 28px; }
  /* 窄屏顶栏占据顶部，提示下移避免遮挡 */
  .toast-host { top: 72px; left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; text-align: center; }
}

/* ---------- 确认弹窗 / 轻提示 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(26, 22, 18, 0.35);
}
.modal-dialog {
  width: min(380px, 100%);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  animation: modal-in 0.16s ease-out;
}
.modal-dialog h2 { margin: 0 0 10px; font-size: 18px; font-weight: 600; }
.modal-dialog p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
  word-break: break-word;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions .btn { padding: 8px 18px; font-size: 14px; }
.modal-actions .btn.ghost { border-color: var(--line); color: var(--ink-soft); }
.modal-actions .btn.ghost:hover { background: var(--paper-2); }
.modal-actions .btn.danger { background: var(--danger); }
.modal-actions .btn.danger:hover { background: #86251a; }
.modal-actions .btn:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.toast-host {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: min(88vw, 420px);
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
  word-break: break-word;
}
.toast.show { opacity: 1; transform: none; }
.toast.leaving { opacity: 0; transform: translateY(-6px); }
.toast.ok { border-color: rgba(47, 111, 78, 0.45); color: var(--ok); }
.toast.error { border-color: rgba(157, 43, 31, 0.45); color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .modal-dialog { animation: none; }
  .toast { transition: none; }
}
