/* 造梦 OS · 对话框首页（chat-shell.js） */
.chat-view {
  --chat-brand: var(--brand-500, #b84c5c);
  --chat-brand-dark: var(--brand-600, #9a3d4b);
  --chat-brand-soft: #fdf2f4;
  --chat-brand-line: #f3c9d0;
  --chat-ink: #1f2430;
  --chat-muted: #6b7280;
  --chat-faint: #9ca3af;
  --chat-line: #eceef2;
  --chat-bg: #fffafa;
  --chat-sidebar-w: 264px;
  position: fixed;
  inset: 0;
  z-index: 5;
  background: var(--chat-bg);
  color: var(--chat-ink);
}
html.auth-restoring #chatView { visibility: hidden; }

.chat-view svg { width: 1.1em; height: 1.1em; flex: none; }
.chat-view button { font-family: inherit; color: inherit; }
.chat-view .chat-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--chat-muted);
}
.chat-view .chat-icon-btn:hover { background: rgba(184, 76, 92, .09); color: var(--chat-brand-dark); }

.chat-app { display: flex; flex-direction: column; height: 100%; }
.chat-layout { flex: 1; display: flex; min-height: 0; }

/* ------------------------------------------------ 侧栏 */
.chat-sidebar {
  width: var(--chat-sidebar-w); flex: none; display: flex; flex-direction: column;
  padding: .85rem .7rem .6rem; background: #fff; border-right: 1px solid var(--chat-line);
  min-height: 0;
}
.chat-side-head { display: flex; align-items: center; gap: .5rem; padding: 0 .35rem .8rem; }
.chat-side-head strong { font-size: 15px; letter-spacing: -.01em; }
.chat-side-close { display: none !important; margin-left: auto; }
.chat-logo-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border-radius: 8px; background: var(--chat-brand); color: #fff;
}
.chat-logo-mark svg { width: 14px; height: 14px; }
.chat-new-btn {
  display: flex; align-items: center; gap: .5rem; width: 100%; padding: .55rem .75rem; border: 0;
  border-radius: 10px; background: var(--chat-brand); color: #fff !important; font-weight: 600; font-size: 14px;
  box-shadow: 0 6px 16px rgba(184, 76, 92, .22);
}
.chat-new-btn:hover { background: var(--chat-brand-dark); }
.chat-search {
  display: flex; align-items: center; gap: .45rem; margin: .6rem 0 .4rem; padding: .42rem .65rem;
  border: 1px solid var(--chat-line); border-radius: 10px; background: #fafafb; color: var(--chat-faint);
  font-size: 13px;
}
.chat-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; color: var(--chat-ink); }
.chat-search kbd {
  font-family: inherit; font-size: 10px; padding: 1px 5px; border: 1px solid var(--chat-line);
  border-radius: 5px; background: #fff; color: var(--chat-faint);
}
.chat-search:focus-within { border-color: var(--chat-brand-line); background: #fff; }
.chat-side-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -.2rem; padding: 0 .2rem; }
.chat-side-section { margin-top: .5rem; }
.chat-side-label {
  display: flex; align-items: center; justify-content: space-between; padding: .3rem .35rem;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--chat-faint);
}
.chat-side-empty { margin: .2rem .35rem .5rem; font-size: 12px; line-height: 1.55; color: var(--chat-faint); }
.chat-side-empty-tight { margin: .1rem .2rem .2rem; }
.chat-ghost-btn {
  display: inline-flex; align-items: center; gap: .35rem; margin: 0 .35rem; padding: .35rem .65rem;
  border: 1px dashed var(--chat-brand-line); border-radius: 9px; background: transparent;
  color: var(--chat-brand-dark); font-size: 12px;
}
.chat-ghost-btn:hover { background: var(--chat-brand-soft); }

.chat-brand { position: relative; margin-bottom: 1px; }
.chat-brand-row { display: flex; align-items: center; gap: 2px; border-radius: 9px; position: relative; }
.chat-brand-row:hover { background: #f6f6f8; }
.chat-brand.is-current .chat-brand-row { background: var(--chat-brand-soft); }
.chat-brand-caret svg { width: 12px; height: 12px; transition: transform .15s; }
.chat-brand.is-expanded .chat-brand-caret svg { transform: rotate(90deg); }
.chat-brand-name {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .45rem; padding: .42rem .2rem;
  border: 0; background: transparent; text-align: left; font-size: 13.5px; font-weight: 500;
}
.chat-brand-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-brand-name svg { color: var(--chat-brand); }
.chat-brand.is-current .chat-brand-name { color: var(--chat-brand-dark); font-weight: 600; }
.chat-brand-more { opacity: 0; }
.chat-brand-row:hover .chat-brand-more, .chat-brand-more:focus-visible { opacity: 1; }
.chat-brand-menu {
  position: absolute; right: 0; top: 100%; z-index: 20; min-width: 130px; padding: .3rem;
  background: #fff; border: 1px solid var(--chat-line); border-radius: 10px; box-shadow: 0 12px 30px rgba(31, 36, 48, .14);
}
.chat-brand-menu button {
  display: flex; width: 100%; align-items: center; gap: .5rem; padding: .45rem .55rem; border: 0;
  border-radius: 7px; background: transparent; font-size: 13px; text-align: left;
}
.chat-brand-menu button:hover { background: #f6f6f8; }
.chat-brand-menu .is-danger { color: #dc2626; }
.chat-brand-children { margin: 1px 0 4px 1.15rem; padding-left: .4rem; border-left: 1px solid var(--chat-line); }

.chat-conv-row { display: flex; align-items: center; border-radius: 8px; }
.chat-conv-row:hover { background: #f6f6f8; }
.chat-conv-row.is-active { background: var(--chat-brand-soft); }
.chat-conv-open {
  flex: 1; min-width: 0; padding: .38rem .5rem; border: 0; background: transparent; text-align: left;
  font-size: 13px; color: #374151;
}
.chat-conv-row.is-active .chat-conv-open { color: var(--chat-brand-dark); font-weight: 600; }
.chat-conv-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-del { opacity: 0; width: 24px; height: 24px; }
.chat-conv-row:hover .chat-conv-del { opacity: 1; }
.chat-search-hit small { display: block; padding: 0 .55rem .35rem; font-size: 11px; color: var(--chat-faint); }

.chat-side-nav { display: grid; gap: 1px; padding: .5rem 0; border-top: 1px solid var(--chat-line); margin-top: .4rem; }
.chat-side-nav button {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; border: 0; border-radius: 9px;
  background: transparent; font-size: 13.5px; text-align: left; color: #374151;
}
.chat-side-nav button svg { color: var(--chat-muted); }
.chat-side-nav button:hover { background: #f6f6f8; }
.chat-side-foot { display: grid; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--chat-line); }
.chat-points {
  display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem;
  border: 1px solid var(--chat-brand-line); border-radius: 10px; background: var(--chat-brand-soft);
  color: var(--chat-brand-dark); font-size: 13px;
}
.chat-points strong { font-size: 15px; }
.chat-points:hover { background: #fbe8eb; }
.chat-account {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .4rem .5rem; border: 0;
  border-radius: 10px; background: transparent; text-align: left;
}
.chat-account:hover { background: #f6f6f8; }
.chat-account > svg { margin-left: auto; color: var(--chat-faint); }
.chat-avatar-dot {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none;
  border-radius: 999px; background: var(--chat-brand); color: #fff; font-weight: 700; font-size: 13px;
}
.chat-account-copy { min-width: 0; display: grid; }
.chat-account-copy strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-account-copy small { font-size: 11px; color: var(--chat-faint); }
.chat-login-btn {
  padding: .6rem; border: 0; border-radius: 10px; background: var(--chat-brand); color: #fff !important; font-weight: 600;
}
.chat-login-btn:hover { background: var(--chat-brand-dark); }
.chat-side-note { margin: 0; font-size: 11.5px; color: var(--chat-faint); text-align: center; }
.chat-icp { font-size: 11px; color: var(--chat-faint); text-align: center; text-decoration: none; }
.chat-icp:hover { color: var(--chat-muted); text-decoration: underline; }

/* ------------------------------------------------ 主区 */
.chat-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto;
  background:
    radial-gradient(900px 380px at 50% -120px, rgba(184, 76, 92, .09), transparent 70%),
    var(--chat-bg);
}
.chat-topbar { display: flex; align-items: center; gap: .6rem; min-height: 48px; padding: .5rem 1rem; flex: none; }
.chat-app[data-mode="welcome"] .chat-topbar { position: sticky; top: 0; z-index: 8; background: rgba(255, 250, 250, .88); backdrop-filter: blur(8px); }
.chat-menu-btn { display: none !important; }
.chat-topbar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; }
.chat-topbar-title strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-topbar-actions { display: flex; align-items: center; gap: .25rem; }
.chat-top-login {
  padding: .35rem .9rem; border: 1px solid var(--chat-brand-line); border-radius: 999px; background: #fff;
  color: var(--chat-brand-dark); font-weight: 600; font-size: 13px;
}
.chat-tag {
  display: inline-flex; align-items: center; gap: .3rem; padding: 2px 9px; border-radius: 999px;
  background: var(--chat-brand-soft); color: var(--chat-brand-dark); font-size: 12px; border: 1px solid var(--chat-brand-line);
}
.chat-app[data-mode="welcome"] .chat-topbar-title { visibility: hidden; }

.chat-hero { display: grid; justify-items: center; gap: .5rem; padding: clamp(1rem, 5vh, 3.5rem) 1rem .6rem; text-align: center; }
.chat-hero-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 16px;
  background: var(--chat-brand); color: #fff; box-shadow: 0 10px 26px rgba(184, 76, 92, .3);
}
.chat-hero-mark svg { width: 24px; height: 24px; }
.chat-hero h1 { display: grid; gap: .1rem; margin: .7rem 0 0; font-size: clamp(1.55rem, 2.8vw, 2.1rem); line-height: 1.25; letter-spacing: -.02em; }
.chat-hero-accent { color: var(--chat-brand); }
.chat-hero p { margin: .2rem 0 0; color: var(--chat-muted); font-size: 14.5px; }
.chat-hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .6rem; }
.chat-hero-tags span {
  display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .75rem; border-radius: 999px;
  background: rgba(255, 255, 255, .85); border: 1px solid var(--chat-brand-line); color: var(--chat-brand-dark); font-size: 12.5px;
}
.chat-hero-tags svg { width: 12px; height: 12px; }

.chat-thread { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: .5rem 1rem 1rem; }
.chat-thread-inner { max-width: 800px; margin: 0 auto; display: grid; gap: 1.4rem; }
.chat-app[data-mode="thread"] .chat-thread { display: block; }
.chat-app[data-mode="thread"] .chat-main { overflow: hidden; }
.chat-app[data-mode="thread"] .chat-hero,
.chat-app[data-mode="thread"] .chat-welcome-extra { display: none; }

.chat-msg { display: flex; gap: .75rem; }
.chat-msg-user { justify-content: flex-end; }
.chat-bubble {
  max-width: min(82%, 640px); padding: .65rem .95rem; border-radius: 16px 16px 4px 16px;
  background: var(--chat-brand); color: #fff; font-size: 14.5px; line-height: 1.65; word-break: break-word;
}
.chat-ai-avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 10px; background: var(--chat-brand-soft); color: var(--chat-brand); border: 1px solid var(--chat-brand-line);
}
.chat-ai-avatar svg { width: 13px; height: 13px; }
.chat-msg-body { min-width: 0; flex: 1; }
.chat-msg-ctx { margin-bottom: .35rem; font-size: 12px; color: var(--chat-faint); }
.chat-md { font-size: 14.5px; line-height: 1.75; word-break: break-word; }
.chat-md > :first-child { margin-top: 0; }
.chat-md > :last-child { margin-bottom: 0; }
.chat-md h1, .chat-md h2, .chat-md h3, .chat-md h4 { margin: 1.1em 0 .45em; line-height: 1.4; letter-spacing: -.01em; }
.chat-md h1 { font-size: 1.25em; } .chat-md h2 { font-size: 1.15em; } .chat-md h3 { font-size: 1.05em; } .chat-md h4 { font-size: 1em; }
.chat-md p { margin: .55em 0; }
.chat-md ul, .chat-md ol { margin: .5em 0; padding-left: 1.35em; }
.chat-md li { margin: .2em 0; }
.chat-md blockquote { margin: .7em 0; padding: .2em .9em; border-left: 3px solid var(--chat-brand-line); color: #4b5563; background: #fff7f8; border-radius: 0 8px 8px 0; }
.chat-md code { padding: .12em .4em; border-radius: 5px; background: #f3f4f6; font-size: .9em; }
.chat-md pre { overflow-x: auto; padding: .8rem 1rem; border-radius: 10px; background: #1f2430; color: #f3f4f6; }
.chat-md pre code { padding: 0; background: transparent; color: inherit; }
.chat-md table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: .8em 0; font-size: .93em; }
.chat-md th, .chat-md td { padding: .45rem .7rem; border: 1px solid var(--chat-line); text-align: left; vertical-align: top; }
.chat-md th { background: #fff5f6; }
.chat-md a { color: var(--chat-brand-dark); }
.chat-md hr { border: 0; border-top: 1px solid var(--chat-line); margin: 1.2em 0; }
.chat-msg-note { display: inline-block; margin-top: .4rem; font-size: 12px; color: var(--chat-faint); }
.chat-msg-note.is-error { color: #dc2626; }
.chat-msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .6rem; }
.chat-msg-actions button {
  display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border: 1px solid var(--chat-line);
  border-radius: 999px; background: #fff; font-size: 12px; color: var(--chat-muted);
}
.chat-msg-actions button:hover { border-color: var(--chat-brand-line); color: var(--chat-brand-dark); background: var(--chat-brand-soft); }
.chat-typing { display: inline-flex; gap: 4px; padding: .45rem 0; }
.chat-typing i { width: 6px; height: 6px; border-radius: 999px; background: var(--chat-brand-line); animation: chat-bounce 1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; } .chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
.chat-msg.is-streaming .chat-md > :last-child::after {
  content: ''; display: inline-block; width: 7px; height: 1.05em; margin-left: 3px; vertical-align: text-bottom;
  background: var(--chat-brand); border-radius: 2px; animation: chat-blink 1s steps(2) infinite;
}
@keyframes chat-blink { 50% { opacity: 0; } }

/* ------------------------------------------------ 输入框 */
.chat-composer-wrap { flex: none; width: 100%; max-width: 800px; margin: 0 auto; padding: .5rem 1rem 0; }
.chat-app[data-mode="thread"] .chat-composer-wrap { padding-bottom: .4rem; }
.chat-composer {
  position: relative; padding: .75rem .85rem .6rem; border: 1.5px solid var(--chat-brand-line); border-radius: 18px;
  background: #fff; box-shadow: 0 14px 40px rgba(184, 76, 92, .1);
  transition: border-color .15s, box-shadow .15s;
}
.chat-composer:focus-within { border-color: var(--chat-brand); box-shadow: 0 14px 40px rgba(184, 76, 92, .16), 0 0 0 3px rgba(184, 76, 92, .08); }
.chat-ctx-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chat-ctx-chips:not(:empty) { margin-bottom: .45rem; }
.chat-chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: 2px 4px 2px 8px; border-radius: 999px;
  background: var(--chat-brand-soft); border: 1px solid var(--chat-brand-line); color: var(--chat-brand-dark); font-size: 12px;
}
.chat-chip button { display: inline-flex; padding: 2px; border: 0; background: transparent; color: inherit; border-radius: 999px; opacity: .6; }
.chat-chip button:hover { opacity: 1; background: rgba(184, 76, 92, .14); }
.chat-chip button svg { width: 11px; height: 11px; }
#chatInput {
  display: block; width: 100%; min-height: 28px; max-height: 220px; padding: .1rem .15rem; resize: none; border: 0;
  outline: 0; background: transparent; font-size: 15px; line-height: 1.65; color: var(--chat-ink);
}
#chatInput::placeholder { color: #b3b8c2; }
.chat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .4rem; }
.chat-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-width: 0; }
.chat-tool {
  display: inline-flex; align-items: center; gap: .3rem; max-width: 150px; padding: .28rem .6rem; border: 1px solid transparent;
  border-radius: 999px; background: transparent; color: var(--chat-muted); font-size: 12.5px;
}
.chat-tool span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tool:hover { background: #f6f6f8; }
.chat-tool.is-on { color: var(--chat-brand-dark); background: var(--chat-brand-soft); border-color: var(--chat-brand-line); }
.chat-tool-icon { padding: .28rem .45rem; }
.chat-send-group { display: flex; align-items: center; gap: .5rem; flex: none; }
.chat-cost { font-size: 11.5px; color: var(--chat-faint); white-space: nowrap; }
.chat-send-btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .95rem; border: 0; border-radius: 999px;
  background: var(--chat-brand); color: #fff !important; font-weight: 600; font-size: 13.5px;
}
.chat-send-btn:hover { background: var(--chat-brand-dark); }
.chat-send-btn.is-stop { background: #374151; }
.chat-disclaimer { margin: .45rem 0 .2rem; text-align: center; font-size: 11px; color: var(--chat-faint); }
.chat-app[data-mode="welcome"] .chat-disclaimer { display: none; }

.chat-popover {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 30; max-height: 320px; overflow-y: auto;
  padding: .4rem; background: #fff; border: 1px solid var(--chat-line); border-radius: 14px;
  box-shadow: 0 18px 44px rgba(31, 36, 48, .16);
}
.chat-pop-title { padding: .3rem .6rem; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--chat-faint); }
.chat-pop-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: 10px;
  background: transparent; text-align: left;
}
.chat-pop-item:hover, .chat-pop-item.is-hover { background: #f6f6f8; }
.chat-pop-item.is-active { background: var(--chat-brand-soft); }
.chat-pop-icon { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 9px; background: var(--chat-brand-soft); color: var(--chat-brand); flex: none; }
.chat-pop-copy { min-width: 0; flex: 1; display: grid; }
.chat-pop-copy strong { font-size: 13.5px; }
.chat-pop-copy small { font-size: 12px; color: var(--chat-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-pop-check { color: var(--chat-brand); font-weight: 700; }

/* ------------------------------------------------ 欢迎页下半部分 */
.chat-welcome-extra { width: 100%; max-width: 800px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.chat-shortcuts { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-bottom: 1.6rem; }
.chat-shortcut {
  padding: .42rem 1.1rem; border: 1px solid var(--chat-brand-line); border-radius: 999px; background: #fff;
  color: var(--chat-brand-dark); font-size: 13px; font-weight: 500;
}
.chat-shortcut:hover { background: var(--chat-brand-soft); }
.chat-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chat-panel { padding: .9rem 1rem; border: 1px solid var(--chat-line); border-radius: 14px; background: #fff; min-width: 0; }
.chat-panel header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; font-size: 13px; }
.chat-panel header button { border: 0; background: transparent; color: var(--chat-brand-dark); font-size: 12px; }
.chat-panel-list { display: grid; gap: 1px; }
.chat-panel-row {
  display: flex; align-items: center; gap: .55rem; padding: .48rem .35rem; border: 0; border-radius: 8px;
  background: transparent; text-align: left; font-size: 13px;
}
.chat-panel-row:hover { background: #fafafb; }
.chat-panel-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-panel-tag { flex: none; font-size: 11px; color: var(--chat-faint); }
.chat-panel-tag.is-brand { padding: 0 7px; border-radius: 5px; background: var(--chat-brand-soft); color: var(--chat-brand-dark); }
.chat-panel-time { flex: none; font-size: 11px; color: var(--chat-faint); }
.chat-dot { width: 7px; height: 7px; border-radius: 999px; flex: none; background: var(--chat-brand); }
.tone-blue { --tone: #3b82f6; } .tone-green { --tone: #16a34a; } .tone-warm { --tone: #d97706; } .tone-pink { --tone: #b84c5c; }
.chat-dot[class*="tone-"] { background: var(--tone); }

/* ------------------------------------------------ 弹层 */
.chat-modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(17, 24, 39, .42); backdrop-filter: blur(3px);
}
.chat-modal-card { position: relative; width: min(440px, 100%); padding: 1.6rem; border-radius: 20px; background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); }
.chat-gate { display: grid; justify-items: center; gap: .6rem; text-align: center; }
.chat-gate h2 { margin: .4rem 0 0; font-size: 1.2rem; }
.chat-gate p { margin: 0; color: var(--chat-muted); font-size: 14px; line-height: 1.65; }
.chat-modal-actions { display: flex; gap: .6rem; margin-top: .6rem; }
.chat-primary-btn, .chat-secondary-btn { padding: .55rem 1.2rem; border-radius: 10px; font-weight: 600; font-size: 14px; }
.chat-primary-btn { border: 0; background: var(--chat-brand); color: #fff !important; }
.chat-primary-btn:hover { background: var(--chat-brand-dark); }
.chat-secondary-btn { border: 1px solid var(--chat-brand-line); background: #fff; color: var(--chat-brand-dark) !important; }
.chat-secondary-btn:hover { background: var(--chat-brand-soft); }
.chat-modal-close { position: absolute; top: .7rem; right: .7rem; display: inline-flex; padding: .35rem; border: 0; border-radius: 8px; background: transparent; color: var(--chat-muted); }
.chat-modal-close:hover { background: #f3f4f6; }
.chat-picker { width: min(860px, 100%); max-height: min(86vh, 760px); overflow-y: auto; }
.chat-picker header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.chat-picker h2 { margin: 0; font-size: 1.15rem; }
.chat-picker header p { margin: .3rem 0 0; color: var(--chat-muted); font-size: 13px; }
.chat-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.chat-skill-card { display: grid; align-content: start; gap: .35rem; padding: 1rem; border: 1px solid var(--chat-line); border-radius: 14px; background: #fff; }
.chat-skill-card:hover { border-color: var(--chat-brand-line); box-shadow: 0 10px 26px rgba(184, 76, 92, .09); }
.chat-skill-icon { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 10px; background: var(--chat-brand-soft); color: var(--tone, var(--chat-brand)); }
.chat-skill-card strong { font-size: 14.5px; }
.chat-skill-card p { margin: 0; color: var(--chat-muted); font-size: 12.5px; line-height: 1.6; }
.chat-skill-actions { display: flex; gap: .45rem; margin-top: .45rem; }
.chat-skill-actions button { padding: .38rem .8rem; font-size: 12.5px; }

/* ------------------------------------------------ 其他 */
.chat-inline-cta {
  display: inline-flex; align-items: center; gap: .35rem; margin-top: .5rem; padding: .35rem .8rem;
  border: 1px solid var(--chat-brand-line); border-radius: 999px; background: var(--chat-brand-soft);
  color: var(--chat-brand-dark); font-size: 12.5px; font-weight: 600;
}
.chat-deep-tag {
  align-self: center; padding: 1px 8px; border-radius: 999px; background: #fff7e6; color: #b45309;
  border: 1px solid #fde4b0; font-size: 11px; white-space: nowrap;
}
.chat-skill-actions { flex-wrap: wrap; }

/* ------------------------------------------------ 响应式：平板 / 手机 */
@media (max-width: 820px) {
  .chat-view { height: 100dvh; bottom: auto; }
  .chat-menu-btn { display: inline-flex !important; }
  .chat-side-close { display: inline-flex !important; }
  .chat-sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 60px rgba(0, 0, 0, .2);
  }
  .chat-backdrop { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(17, 24, 39, .4); }
  .chat-app.is-sidebar-open .chat-sidebar { transform: none; }
  .chat-app.is-sidebar-open .chat-backdrop { display: block; }
  .chat-panels { grid-template-columns: 1fr; }
  .chat-topbar-title { visibility: visible !important; }
  .chat-app[data-mode="welcome"] .chat-topbar-title strong { display: none; }
}

@media (max-width: 640px) {
  /* 顶栏 / 欢迎区：更紧凑，去掉说明文字 */
  .chat-topbar { min-height: 44px; padding: .35rem .6rem; }
  .chat-hero { padding: 1rem .9rem .2rem; gap: .25rem; }
  .chat-hero-mark { width: 40px; height: 40px; border-radius: 13px; }
  .chat-hero-mark svg { width: 19px; height: 19px; }
  .chat-hero h1 { margin-top: .35rem; font-size: 1.5rem; }
  .chat-hero p { font-size: 13px; }
  .chat-hero-tags { gap: .35rem; margin-top: .4rem; }
  .chat-hero-tags span { padding: .22rem .6rem; font-size: 12px; }

  /* 输入框：图标工具栏，字号 16px 防止 iOS 放大 */
  .chat-composer-wrap { padding: .4rem .6rem 0; }
  .chat-app[data-mode="thread"] .chat-composer-wrap { padding-bottom: max(.4rem, env(safe-area-inset-bottom)); }
  .chat-composer { padding: .6rem .65rem .5rem; border-radius: 16px; }
  #chatInput { font-size: 16px; line-height: 1.55; max-height: 38vh; }
  .chat-toolbar { margin-top: .3rem; gap: .35rem; }
  .chat-tools { flex-wrap: nowrap; gap: .1rem; }
  .chat-tool { max-width: none; padding: .42rem .5rem; }
  .chat-tool span { display: none; }
  .chat-tool svg { width: 1.25em; height: 1.25em; }
  .chat-cost, .chat-disclaimer { display: none; }
  .chat-send-btn { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 999px; }
  .chat-send-btn span { display: none; }
  .chat-send-btn svg { width: 1.2em; height: 1.2em; }
  .chat-chip { max-width: 46vw; font-size: 11.5px; }
  .chat-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 快捷入口：一行横滑 */
  .chat-welcome-extra { padding: .6rem .6rem 1.5rem; }
  .chat-shortcuts { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; gap: .45rem; margin: 0 -.6rem 1rem; padding: 0 .6rem .2rem; scrollbar-width: none; }
  .chat-shortcuts::-webkit-scrollbar { display: none; }
  .chat-shortcut { flex: none; padding: .38rem .85rem; }
  .chat-panel { padding: .7rem .75rem; }
  .chat-panel-tag, .chat-panel-time { display: none; }
  .chat-panel-tag.is-brand { display: inline-block; }

  /* 对话气泡 / 回复 */
  .chat-thread { padding: .25rem .7rem .8rem; }
  .chat-thread-inner { gap: 1rem; }
  .chat-bubble { max-width: 92%; font-size: 14px; padding: .55rem .8rem; }
  .chat-ai-avatar { width: 26px; height: 26px; border-radius: 9px; }
  .chat-msg { gap: .5rem; }
  .chat-md { font-size: 14px; line-height: 1.7; }
  .chat-md pre { font-size: 12px; }
  .chat-msg-ctx { font-size: 11px; }
  /* 消息操作：只留图标 */
  .chat-msg-actions button { padding: .35rem .55rem; }
  .chat-msg-actions button span { display: none; }
  .chat-msg-actions button svg { width: 1.2em; height: 1.2em; }

  /* 侧栏抽屉 / 弹层 */
  .chat-modal { align-items: flex-end; padding: 0; }
  .chat-modal-card { width: 100%; border-radius: 20px 20px 0 0; padding: 1.2rem 1rem max(1rem, env(safe-area-inset-bottom)); }
  .chat-picker { max-height: 88dvh; }
  .chat-picker-grid { grid-template-columns: 1fr; gap: .6rem; }
  .chat-skill-card { padding: .8rem; }
  .chat-skill-card p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing i, .chat-msg.is-streaming .chat-md > :last-child::after { animation: none; }
}

/* 旧首页在恢复登录态阶段不再闪现；账号菜单要盖过移动端侧栏 */
html.auth-restoring #workspaceHomeView { display: none !important; }
#accountMenu { z-index: 70; }

.chat-composer #chatInput, .chat-composer #chatInput:focus, .chat-composer #chatInput:focus-visible { border: 0 !important; outline: 0 !important; box-shadow: none !important; background: transparent !important; border-radius: 0; }

#chatView { overflow: hidden; }
#chatView .chat-app { max-height: 100%; }

/* ------------------------------------------------ 首页优化：邀请入口 / 常用技能 / 推荐提问 */
.chat-invite-pill {
  display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .8rem .3rem .35rem; border: 1px solid var(--chat-brand-line);
  border-radius: 999px; background: #fff; box-shadow: 0 4px 14px rgba(184, 76, 92, .1); text-align: left;
  transition: box-shadow .15s, transform .15s;
}
.chat-invite-pill:hover { box-shadow: 0 8px 20px rgba(184, 76, 92, .18); transform: translateY(-1px); }
.chat-invite-pill-ico, .chat-invite-banner-ico, .chat-nudge-ico {
  display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 999px;
  background: var(--chat-brand-soft); color: var(--chat-brand);
}
.chat-invite-pill-ico { width: 28px; height: 28px; }
.chat-invite-pill-copy { display: grid; line-height: 1.25; }
.chat-invite-pill-copy strong { font-size: 12.5px; color: var(--chat-brand-dark); }
.chat-invite-pill-copy small { font-size: 11px; color: var(--chat-muted); }

.chat-composer-invite { display: none; }
.chat-app[data-mode="welcome"] .chat-composer-invite { display: block; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--chat-brand-line); }
.chat-invite-banner {
  display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .7rem; border: 0; border-radius: 12px;
  background: linear-gradient(90deg, #fdeef1, #fff6f0); text-align: left; transition: filter .15s;
}
.chat-invite-banner:hover { filter: brightness(.98); }
.chat-invite-banner-ico { width: 34px; height: 34px; background: #fff; box-shadow: 0 2px 8px rgba(184, 76, 92, .15); }
.chat-invite-banner-ico svg { width: 18px; height: 18px; }
.chat-invite-banner-copy { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.chat-invite-banner-copy strong { font-size: 13.5px; color: var(--chat-brand-dark); }
.chat-invite-banner-copy small { font-size: 12px; color: var(--chat-muted); }
.chat-invite-banner > svg { color: var(--chat-brand); width: 16px; height: 16px; }

.chat-welcome-extra { max-width: 800px; display: grid; gap: 1.5rem; padding-top: 1.6rem; }
.chat-block header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.chat-block header strong { font-size: 14.5px; }
.chat-block header button { border: 0; background: transparent; color: var(--chat-brand-dark); font-size: 12.5px; }
.chat-block header button:hover { text-decoration: underline; }

.chat-skill-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.chat-skill-tile {
  display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; border: 1px solid var(--chat-line); border-radius: 16px;
  background: #fff; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.chat-skill-tile:hover { border-color: var(--chat-brand-line); box-shadow: 0 10px 26px rgba(184, 76, 92, .1); transform: translateY(-1px); }
.chat-tile-ico, .chat-ask-ico, .chat-recent-ico, .chat-perk-ico {
  display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 12px;
  background: var(--chat-brand-soft); color: var(--chat-brand);
}
.chat-tile-ico { width: 40px; height: 40px; }
.chat-tile-ico svg { width: 20px; height: 20px; }
.chat-tile-copy { min-width: 0; display: grid; gap: .1rem; }
.chat-tile-copy strong { font-size: 14px; }
.chat-tile-copy small { font-size: 12px; line-height: 1.5; color: var(--chat-muted); }

.chat-recent-list { display: grid; gap: .4rem; }
.chat-recent-row {
  display: flex; align-items: center; gap: .65rem; padding: .6rem .8rem; border: 1px solid var(--chat-line); border-radius: 12px;
  background: #fff; text-align: left; font-size: 13.5px; transition: border-color .15s, background .15s;
}
.chat-recent-row:hover { border-color: var(--chat-brand-line); background: #fffafb; }
.chat-recent-ico { width: 28px; height: 28px; border-radius: 9px; }
.chat-recent-ico svg { width: 14px; height: 14px; }
.chat-recent-list .chat-side-empty { padding: .8rem 0; margin: 0; }

.chat-ask-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.chat-ask-card {
  display: grid; justify-items: start; align-content: start; gap: .55rem; padding: .85rem .9rem; border: 1px solid var(--chat-line);
  border-radius: 14px; background: #fff; text-align: left; font-size: 13px; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.chat-ask-card:hover { border-color: var(--chat-brand-line); box-shadow: 0 10px 26px rgba(184, 76, 92, .1); transform: translateY(-1px); }
.chat-ask-ico { width: 30px; height: 30px; border-radius: 10px; }
.chat-ask-ico svg { width: 15px; height: 15px; }

/* 回答后再次触达 */
.chat-nudge {
  position: relative; display: flex; gap: .75rem; margin-top: .9rem; padding: .85rem 2.2rem .85rem .9rem; border-radius: 14px;
  background: linear-gradient(90deg, #fdeef1, #fff7f1); border: 1px solid var(--chat-brand-line);
}
.chat-nudge-ico { width: 38px; height: 38px; background: #fff; box-shadow: 0 2px 8px rgba(184, 76, 92, .15); }
.chat-nudge-ico svg { width: 19px; height: 19px; }
.chat-nudge-copy { min-width: 0; display: grid; gap: .2rem; }
.chat-nudge-copy strong { font-size: 14px; }
.chat-nudge-copy small { font-size: 12.5px; line-height: 1.55; color: var(--chat-muted); }
.chat-nudge-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .45rem; }
.chat-nudge-actions button { padding: .38rem .95rem; font-size: 13px; }
.chat-nudge-close { position: absolute; top: .5rem; right: .5rem; width: 24px; height: 24px; }

/* 邀请好友弹层 */
.chat-invite-modal { width: min(440px, 100%); display: grid; justify-items: center; gap: .7rem; text-align: center; padding-top: 1.2rem; }
.chat-invite-art { width: 100%; max-width: 240px; }
.chat-invite-art svg { width: 100%; height: auto; display: block; }
.chat-invite-modal h2 { margin: 0; font-size: 1.25rem; }
.chat-invite-sub { margin: 0; color: var(--chat-muted); font-size: 14px; }
.chat-invite-sub b { color: var(--chat-brand); font-size: 1.05em; }
.chat-invite-perks { list-style: none; margin: .3rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; width: 100%; }
.chat-invite-perks li {
  display: grid; grid-template-columns: auto 1fr; column-gap: .55rem; align-items: center; padding: .6rem .65rem;
  border: 1px solid var(--chat-line); border-radius: 12px; text-align: left; background: #fffafb;
}
.chat-perk-ico { grid-row: span 2; width: 30px; height: 30px; border-radius: 999px; }
.chat-perk-ico svg { width: 15px; height: 15px; }
.chat-invite-perks strong { font-size: 13px; }
.chat-invite-perks small { font-size: 11.5px; line-height: 1.4; color: var(--chat-muted); }
.chat-invite-copy { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; width: 100%; padding: .7rem 1rem; font-size: 15px; border-radius: 999px; }
.chat-invite-copy:disabled, .chat-invite-share button:disabled { opacity: .55; cursor: default; }
.chat-invite-share { display: flex; justify-content: center; gap: 1.6rem; margin-top: .2rem; }
.chat-invite-share button { display: grid; justify-items: center; gap: .3rem; border: 0; background: transparent; font-size: 12px; color: var(--chat-muted); }
.chat-invite-share i {
  display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 999px; color: #fff; font-style: normal;
}
.chat-invite-share i svg { width: 20px; height: 20px; }
.chat-invite-share .is-wechat { background: #22b35e; }
.chat-invite-share .is-link { background: #3b82f6; }
.chat-invite-share .is-more { background: #9ca3af; }
.chat-invite-detail { border: 0; background: transparent; color: var(--chat-brand-dark); font-size: 12.5px; }
.chat-invite-detail:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .chat-invite-pill { padding: .25rem .6rem .25rem .3rem; }
  .chat-invite-pill-ico { width: 24px; height: 24px; }
  .chat-invite-pill-ico svg { width: 13px; height: 13px; }
  .chat-invite-pill-copy strong { font-size: 12px; }
  .chat-invite-pill-copy small { font-size: 10.5px; }
  .chat-app[data-mode="thread"] .chat-invite-pill { display: none; }
  .chat-welcome-extra { gap: 1.2rem; padding-top: 1rem; }
  .chat-skill-tiles { gap: .55rem; }
  .chat-skill-tile { flex-direction: column; align-items: flex-start; gap: .5rem; padding: .75rem; }
  .chat-skill-tile .chat-tile-copy small { display: block; }
  .chat-ask-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .chat-recent-row .chat-panel-time { display: inline; }
  .chat-nudge { padding-right: 2rem; }
  .chat-invite-perks small { display: block; }
  .chat-skill-card p { display: none; }
}

/* ------------------------------------------------ 新手指引 */
.chat-tour { position: fixed; inset: 0; z-index: 90; }
.chat-tour-spot {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(17, 24, 39, .56), 0 0 0 2px rgba(255, 255, 255, .9) inset, 0 0 0 3px var(--chat-brand);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
}
.chat-tour-card {
  position: fixed; box-sizing: border-box; padding: 1rem 1.1rem .95rem; border-radius: 16px; background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3); transition: left .25s ease, top .25s ease;
}
.chat-tour-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .2rem; }
.chat-tour-step { font-size: 12px; font-weight: 600; color: var(--chat-brand); }
.chat-tour-card h3 { margin: .1rem 0 .45rem; font-size: 1.05rem; }
.chat-tour-card ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .3rem; font-size: 13.5px; line-height: 1.6; color: #4b5563; }
.chat-tour-dots { display: flex; gap: 5px; margin: .8rem 0 .2rem; }
.chat-tour-dots i { width: 6px; height: 6px; border-radius: 999px; background: #e5e7eb; transition: width .2s, background .2s; }
.chat-tour-dots i.is-on { width: 16px; background: var(--chat-brand); }
.chat-tour-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .7rem; }
.chat-tour-actions button { padding: .45rem 1rem; font-size: 13.5px; }
.chat-tour-skip { margin-right: auto; border: 0; background: transparent; color: var(--chat-faint); font-size: 13px !important; }
.chat-tour-skip:hover { color: var(--chat-muted); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .chat-tour-spot, .chat-tour-card { transition: none; }
}
