/* ============================================================
   合规智能体 UI v4 — 柔和现代 · 可折叠侧栏 · 完整设置
   ------------------------------------------------------------
   字体规范（Type Scale）
   --fs-2xs 11  区隔标签 / 角标 / 免责声明
   --fs-xs  12  说明、meta、chip、辅助
   --fs-sm  13  次级 UI：字段标签、折叠头、小按钮
   --fs-md  14  主 UI：侧栏项、导航、常规控件
   --fs-lg  15  对话正文 / 输入框
   --fs-xl  17  顶栏标题 / 区块强调（少用）
   --fs-2xl 22  设置/知识库页面 H1
   --fs-3xl 28  欢迎页大标题

   字重：400 / 500 / 600 / 700（不用 550、650）
   行高：tight 1.25 · snug 1.4 · body 1.55 · prose 1.7
   ============================================================ */

:root {
  /* ChatGPT-like：干净中性白/灰（无暖黄） */
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-side: #f7f7f8;
  --bg-side-hover: rgba(0, 0, 0, 0.045);
  --bg-side-active: rgba(0, 0, 0, 0.07);
  --ink: #0d0d0d;
  --ink-soft: #2f2f2f;
  --muted: #8e8e8e;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --accent: #0d0d0d;
  --accent-soft: rgba(0, 0, 0, 0.06);
  --accent-ink: #0d0d0d;
  --user-bg: #f4f4f4;
  /* At 50% over the white chat surface, #e9e9e9 composites to #f4f4f4. */
  --assistant-bg: #e9e9e9;
  --danger: #c23b2e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-lg: 24px;
  --side-w: 320px;
  --side-w-collapsed: 0px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --content-w: 48rem;

  /* Font families */
  --font-site: "Bouquet App", "Noto Serif TC", "Songti TC", serif;
  --font-ui: var(--font-site);
  --font: var(--font-site);
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

  /* Type scale */
  --fs-2xs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 17px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;

  /* Weights（系统字体稳定档） */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Line heights */
  --lh-tight: 1.25;
  --lh-snug: 1.4;
  --lh-body: 1.55;
  --lh-prose: 1.7;

  --max: var(--content-w);
  --content-gutter: 16px;
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
}

/* In-page secondary settings view: modal layout modeled on the reference
   management screen. The workbench sidebar remains in place underneath the
   backdrop and the secondary content owns its scroll area. */
body.settings-subpage-open {
  overflow: hidden;
}

#viewSettings .settings-subpage {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 24px;
  overflow: auto;
}

#viewSettings .settings-subpage[hidden] {
  display: none !important;
}

#viewSettings .settings-subpage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 35, 45, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#viewSettings .settings-subpage-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(760px, calc(100dvh - 48px));
  min-height: 0;
  overflow: hidden;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 26px 90px rgba(25, 32, 54, 0.28);
}

#viewSettings .settings-subpage-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  margin: 0;
  padding: 0 24px;
  border-bottom: 1px solid #e7e9f0;
  box-sizing: border-box;
}

#viewSettings .settings-subpage-header h2 {
  margin: 0;
  color: #0d0d0d;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

#viewSettings .settings-close-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #30343b;
  background: #f1f2f4;
  cursor: pointer;
}

#viewSettings .settings-close-button:hover {
  background: #e7e9ed;
}

#viewSettings .settings-close-button svg {
  width: 19px;
  height: 19px;
}

#viewSettings .settings-subpage-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 24px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

#viewSettings .settings-subpage-content::-webkit-scrollbar {
  width: 10px;
}

#viewSettings .settings-subpage-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

#viewSettings .settings-subpage-content .client-section.md-settings-card {
  width: 100%;
  max-width: none;
}

@media (max-width: 680px) {
  #viewSettings .settings-subpage {
    padding: 12px;
  }

  #viewSettings .settings-subpage-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  #viewSettings .settings-subpage-header {
    min-height: 64px;
    padding-inline: 16px;
  }

  #viewSettings .settings-subpage-content {
    padding: 14px 12px 16px;
  }
}

/* Quick replies: keep the secondary page at the document root so its mask
   covers the complete workbench, including the existing sidebar. */
body.settings-subpage-open {
  overflow: hidden;
}

.settings-subpage {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 24px;
  overflow: auto;
}

.settings-subpage[hidden] {
  display: none !important;
}

.settings-subpage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 29, 36, 0.46);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.settings-subpage-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(760px, calc(100dvh - 48px));
  min-height: 0;
  overflow: hidden;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(17, 24, 39, 0.3);
}

.settings-subpage-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  margin: 0;
  padding: 0 24px;
  border-bottom: 1px solid #e7e9f0;
  box-sizing: border-box;
}

.settings-subpage-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.settings-subpage-header h2 {
  margin: 0;
  color: #0d0d0d;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.settings-subpage-back-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.settings-subpage-back-button svg {
  width: 18px;
  height: 18px;
  color: #30343b;
  stroke-width: 2.25;
}

.settings-subpage-back-button:hover {
  background: #f1f2f4;
}

.settings-subpage-back-button:hover svg {
  color: #000;
}

.settings-subpage-back-button:active {
  background: #e7e9ed;
  transform: scale(0.96);
}

.settings-subpage-back-button:focus-visible {
  outline: 2px solid rgba(23, 105, 245, 0.55);
  outline-offset: 2px;
}

.settings-close-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #30343b;
  background: #f1f2f4;
  cursor: pointer;
}

.settings-close-button:hover {
  background: #e7e9ed;
}

.settings-close-button svg {
  width: 19px;
  height: 19px;
}

.settings-subpage-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 24px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

.settings-subpage-content::-webkit-scrollbar {
  width: 10px;
}

.settings-subpage-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

#settingsQuickRepliesPage #sec-quick-replies {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #f4f4f5;
  box-shadow: none;
}

#settingsQuickRepliesPage #quickReplyForm {
  display: block;
  margin: 0;
}

#settingsQuickRepliesPage .quick-reply-create-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 16px;
  box-sizing: border-box;
}

#settingsQuickRepliesPage #quickReplyText {
  flex: 1 1 auto;
  width: 100%;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  color: #1e293b;
  background: #fff;
  outline: none;
}

#settingsQuickRepliesPage #quickReplyText:focus {
  border-color: rgba(0, 0, 0, 0.28);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

#settingsQuickRepliesPage #btnAddQuickReply {
  flex: 0 0 auto;
  height: 40px;
  min-width: 72px;
  padding: 0 16px;
  white-space: nowrap;
}

#settingsQuickRepliesPage .quick-replies-settings-list {
  display: grid;
  margin: 0;
  padding: 0 16px;
}

#settingsQuickRepliesPage .settings-subpage-content {
  padding-block: 20px;
}

#settingsQuickRepliesPage .quick-replies-settings-list:empty {
  display: none;
}

#settingsQuickRepliesPage .quick-reply-setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 10px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

#settingsQuickRepliesPage .quick-reply-setting-text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #1e293b;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

#settingsQuickRepliesPage .quick-reply-setting-item .admin-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

@media (max-width: 680px) {
  .settings-subpage {
    padding: 12px;
  }

  .settings-subpage-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  .settings-subpage-header {
    min-height: 64px;
    padding-inline: 16px;
  }

  .settings-subpage-content {
    padding: 14px 12px 16px;
  }

  #settingsQuickRepliesPage .quick-reply-create-row {
    align-items: stretch;
  }

  #settingsQuickRepliesPage #quickReplyText,
  #settingsQuickRepliesPage #btnAddQuickReply {
    height: 40px;
    min-height: 40px;
  }

  #settingsQuickRepliesPage .quick-reply-setting-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

/* Legacy duplicate auth block disabled; the final auth overrides are at EOF.
@media (min-width: 801px) {
  .auth-view {
    padding: 38px 28px;
    background: #f5f5f3;
  }

  .auth-shell,
  .auth-shell:has(#registerForm:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(250px, .82fr) minmax(420px, 1.18fr);
    align-items: center;
    gap: clamp(52px, 7vw, 92px);
    width: min(100%, 1000px);
    margin: auto;
    padding: 56px 64px;
    border: 0;
    border-radius: 28px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(17, 17, 17, .09);
  }

  .auth-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    align-self: start;
    justify-self: start;
    gap: 22px;
    margin: 0;
  }

  .auth-logo {
    width: 58px;
    height: 58px;
    box-shadow: none;
  }

  .auth-kicker {
    margin-bottom: 8px;
    color: #777;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .14em;
  }

  .auth-brand h1 {
    color: #111;
    font-size: clamp(34px, 4vw, 48px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -.045em;
  }

  .auth-brand p:last-child {
    color: #777;
  }

  .auth-form {
    grid-column: 2;
    align-self: center;
    gap: 14px;
  }

  #registerForm,
  #resetForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
  }

  #registerForm > .verification-row,
  #registerForm > #registerTencentCaptcha,
  #registerForm > .agreement-open,
  #registerForm > .check-row,
  #registerForm > .auth-error,
  #registerForm > .auth-submit,
  #registerForm > .auth-links,
  #resetForm > .field:first-child,
  #resetForm > .verification-row,
  #resetForm > #resetTencentCaptcha,
  #resetForm > .auth-error,
  #resetForm > .auth-submit,
  #resetForm > .auth-links {
    grid-column: 1 / -1;
  }

  .auth-form .field-label {
    color: #444;
    font-size: 13px;
    font-weight: 500;
  }

  .auth-form input,
  .auth-form select {
    min-height: 46px;
    border-color: #d8d8d4;
    border-radius: 10px;
    color: #111;
    background: #fff;
  }

  .auth-form input:hover,
  .auth-form select:hover {
    border-color: #999;
  }

  .auth-form input:focus,
  .auth-form select:focus {
    border-color: #111;
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .08);
  }

  .auth-submit,
  .btn.primary,
  .send {
    color: #fff;
    background: #111;
    border-color: #111;
    box-shadow: 0 10px 24px rgba(17, 17, 17, .14);
  }

  .auth-submit:hover,
  .btn.primary:hover,
  .send:hover:not(:disabled) {
    color: #fff;
    background: #2b2b2b;
    border-color: #2b2b2b;
    box-shadow: 0 12px 28px rgba(17, 17, 17, .18);
  }

  .auth-links button,
  .agreement-open {
    color: #111;
    text-decoration-color: rgba(17, 17, 17, .28);
  }

  .auth-links button:hover,
  .agreement-open:hover {
    color: #555;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 132px;
    align-items: start;
    gap: 10px;
  }

  .verification-row > .field {
    min-width: 0;
  }

  .verification-row > .btn {
    align-self: start;
    width: 132px;
    height: 46px;
    margin: 25px 0 0;
    padding-inline: 10px;
    border-radius: 10px;
    white-space: nowrap;
  }

  .check-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    color: #555;
    line-height: 1.5;
  }

  .check-row input {
    width: 16px !important;
    height: 16px;
    min-height: 16px;
    margin: 2px 0 0;
  }

  .check-row span {
    min-width: 0;
  }
}

@media (max-width: 800px) {
  .auth-view {
    min-height: 100dvh;
    padding: 18px 14px;
    background: #f5f5f3;
  }

  .auth-shell,
  .auth-shell:has(#registerForm:not([hidden])) {
    display: grid;
    grid-template-columns: 1fr;
    width: min(100%, 560px);
    margin: auto;
    padding: 30px 24px;
    border: 0;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 18px 54px rgba(17, 17, 17, .09);
  }

  .auth-brand {
    margin-bottom: 26px;
  }

  .auth-form {
    grid-column: 1;
  }

  #registerForm,
  #resetForm {
    grid-template-columns: 1fr;
  }

  #registerForm > *,
  #resetForm > * {
    grid-column: 1;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 118px;
    align-items: start;
  }

  .verification-row > .btn {
    width: 118px;
    height: 46px;
    margin-top: 25px;
    padding-inline: 8px;
    font-size: 12px;
  }

  .check-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  .check-row input {
    min-height: 16px;
    margin-top: 2px;
  }
}

/* Settings rows follow the downloader settings source: one item per line,
   shared label alignment, 36px controls, and soft grouped surfaces. */
.settings-layout {
  width: min(720px, 100%);
  margin-inline: auto;
  padding: 36px clamp(24px, 7vw, 72px) 80px;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-stack > .client-section {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #f4f4f5;
  box-shadow: none;
}

.settings-stack > .client-section .section-title {
  margin: 0;
  padding: 16px 16px 7px;
  color: #8e8e93;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
}

.settings-stack > .client-section .section-head {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 16px 16px 7px;
}

.settings-stack > .client-section .section-head .section-title {
  padding: 0;
}

.settings-stack > .client-section .section-head .field-help {
  width: 100%;
}

.settings-stack > .client-section .field-stack,
.settings-stack > .client-section .assistant-form-grid,
.settings-stack > .client-section .assistant-form,
.settings-stack > .client-section .quick-reply-form,
.settings-stack > .client-section .inline-setting-form {
  gap: 0;
}

.settings-stack > .client-section .field.field-row,
.settings-stack > .client-section .assistant-form-grid > .field:not(.field-checkbox),
.settings-stack > .client-section .assistant-form > .field:not(.field-checkbox),
.settings-stack > .client-section .quick-reply-form > .field,
.settings-stack > .client-section .inline-setting-form > .field {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  min-width: 0;
  min-height: 52px;
  margin: 0;
  padding: 8px 16px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(0, 0, 0, .04);
}

.settings-stack > .client-section .field.field-row:last-child,
.settings-stack > .client-section .assistant-form-grid > .field:last-child,
.settings-stack > .client-section .quick-reply-form > .field:last-of-type,
.settings-stack > .client-section .inline-setting-form > .field:last-of-type {
  border-bottom: 0;
}

.settings-stack > .client-section .field.field-row:hover,
.settings-stack > .client-section .assistant-form-grid > .field:hover,
.settings-stack > .client-section .quick-reply-form > .field:hover,
.settings-stack > .client-section .inline-setting-form > .field:hover {
  background: rgba(0, 0, 0, .025);
}

.settings-stack > .client-section .field-label {
  min-width: 0;
  color: #5f6368;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-stack > .client-section .field.field-row input,
.settings-stack > .client-section .field.field-row select,
.settings-stack > .client-section .field input,
.settings-stack > .client-section .field textarea,
.settings-stack > .client-section .field select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  height: 36px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid #dedee2;
  border-radius: 10px;
  color: #202124;
  background: #fff;
  font-size: 13.5px;
}

.settings-stack > .client-section .field textarea {
  height: auto;
  min-height: 112px;
  padding-block: 10px;
  resize: vertical;
  line-height: 1.55;
}

.settings-stack > .client-section .field.field-row input:focus,
.settings-stack > .client-section .field.field-row select:focus,
.settings-stack > .client-section .field input:focus,
.settings-stack > .client-section .field textarea:focus,
.settings-stack > .client-section .field select:focus {
  border-color: #9aa0a6;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .06);
}

.settings-stack > .client-section .field-help {
  padding: 8px 16px 14px;
  color: #8e8e93;
  font-size: 12px;
  line-height: 1.5;
}

.settings-stack > .client-section .app-key-row {
  align-items: start;
  padding-block: 12px;
}

.settings-stack > .client-section .app-key-setting,
.settings-stack > .client-section .app-key-control,
.settings-stack > .client-section .app-key-actions {
  min-width: 0;
}

.settings-stack > .client-section .app-key-control,
.settings-stack > .client-section .app-key-actions,
.settings-stack > .client-section .setting-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-stack > .client-section .app-key-actions {
  padding-top: 8px;
}

.settings-stack > .client-section .app-key-actions .field-help {
  padding: 0;
}

.settings-stack > .client-section .field.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  margin: 0;
  padding: 0 16px;
  border-bottom: 1px solid rgba(0, 0, 0, .04);
}

.settings-stack > .client-section .field.field-checkbox input {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
}

.settings-stack > .client-section .field.field-checkbox span {
  color: #202124;
  font-size: 14px;
}

.settings-stack > .client-section .assistant-form,
.settings-stack > .client-section .quick-reply-form,
.settings-stack > .client-section .inline-setting-form {
  display: flex;
  flex-direction: column;
}

.settings-stack > .client-section .assistant-form > .field:not(.field-checkbox) {
  grid-template-columns: 100px minmax(0, 1fr);
}

.settings-stack > .client-section .assistant-form > .field.field-checkbox {
  border-top: 1px solid rgba(0, 0, 0, .04);
}

.settings-stack > .client-section .setting-actions {
  min-height: 52px;
  padding: 8px 16px 12px;
}

.settings-stack > .client-section .quick-replies-settings-list,
.settings-stack > .client-section #diagInfo {
  padding-inline: 16px;
}

.settings-stack > .client-section #diagInfo {
  padding-bottom: 12px;
}

.agreement-copy h2 {
  margin: 28px 0 10px;
  padding-bottom: 6px;
  color: #243453;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 700;
  border-bottom: 1px solid rgba(36, 52, 83, .14);
}

.agreement-copy h3 {
  margin: 18px 0 6px;
  color: #344563;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 700;
}

.agreement-copy .legal-subsection {
  margin: 8px 0 0;
  padding-left: 1em;
  color: #667085;
  font-size: 13px;
  line-height: 1.8;
}

.agreement-copy .legal-subsection strong {
  color: #52627f;
  font-weight: 700;
}

@media (max-width: 680px) {
  .settings-layout {
    width: 100%;
    padding: 24px 14px 64px;
  }

  .settings-stack > .client-section .field.field-row,
  .settings-stack > .client-section .assistant-form-grid > .field:not(.field-checkbox),
  .settings-stack > .client-section .assistant-form > .field:not(.field-checkbox),
  .settings-stack > .client-section .quick-reply-form > .field,
  .settings-stack > .client-section .inline-setting-form > .field {
    grid-template-columns: 88px minmax(0, 1fr);
    column-gap: 8px;
    padding-inline: 12px;
  }

  .settings-stack > .client-section .field.field-checkbox,
  .settings-stack > .client-section .setting-actions,
  .settings-stack > .client-section .quick-replies-settings-list,
  .settings-stack > .client-section #diagInfo {
    padding-inline: 12px;
  }
}

/* Settings secondary page: same grouped-row language, without touching the workbench sidebar. */
#viewSettings .settings-subpage.md-settings-container {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0;
  padding: 0 0 40px;
}

#viewSettings .settings-subpage-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 36px;
  margin: 0 0 18px;
}

#viewSettings .settings-subpage-header h2 {
  grid-column: 2;
  margin: 0;
  color: #0d0d0d;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

#viewSettings .settings-back-button {
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: 32px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #1e293b;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

#viewSettings .settings-back-button svg {
  width: 16px;
  height: 16px;
}

#viewSettings .settings-entry-card {
  overflow: hidden;
}

#viewSettings .settings-entry-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: #1e293b;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

#viewSettings .settings-entry-button:hover {
  background: rgba(0, 0, 0, 0.025);
}

#viewSettings .settings-entry-button svg {
  width: 16px;
  height: 16px;
  color: #8e8e93;
}

#viewSettings #sec-quick-replies .quick-reply-form {
  overflow: hidden;
}

#viewSettings #sec-quick-replies .quick-replies-settings-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0 16px;
}

#viewSettings #sec-quick-replies .quick-reply-setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

#viewSettings #sec-quick-replies .quick-reply-setting-item strong,
#viewSettings #sec-quick-replies .quick-reply-setting-item p {
  display: block;
  margin: 0;
}

#viewSettings #sec-quick-replies .quick-reply-setting-item strong {
  color: #1e293b;
  font-size: 14px;
  font-weight: 600;
}

#viewSettings #sec-quick-replies .quick-reply-setting-item p {
  margin-top: 4px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#viewSettings #sec-quick-replies .quick-reply-setting-item .admin-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

@media (max-width: 680px) {
  #viewSettings .settings-subpage.md-settings-container {
    max-width: none;
  }

  #viewSettings #sec-quick-replies .quick-reply-setting-item {
    align-items: flex-start;
    flex-direction: column;
  }

  #viewSettings #sec-quick-replies .quick-reply-setting-item .admin-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Downloader web UI parity for the workbench settings document. */
.view[data-view="settings"].is-active {
  display: flex !important;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

#scrollSettings.page-scroll {
  flex: 1 1 auto;
  height: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
  background: #ffffff;
}

#scrollSettings.page-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#scrollSettings.page-scroll::-webkit-scrollbar-track {
  background: transparent;
}

#scrollSettings.page-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

#scrollSettings.page-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.settings-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 100%;
  padding: 36px clamp(72px, 18vw, 240px) 80px;
}

.settings-hero,
.settings-stack {
  width: 100%;
  max-width: 720px;
}

.settings-hero {
  margin: 0 auto 18px;
  padding-bottom: 8px;
}

.settings-hero h1 {
  margin: 0 0 6px;
  color: #0d0d0d;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.settings-hero p {
  margin: 0;
  color: #8e8e93;
  font-size: 14px;
  line-height: 1.5;
}

.settings-stack {
  display: grid;
  align-content: start;
  gap: 4px;
  margin-top: 0;
}

.settings-stack > .client-section {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #f4f4f5;
  border: 0;
  border-radius: 14px;
  box-shadow: none;
}

.settings-stack > .client-section > .section-title,
.settings-stack > .client-section > .section-head {
  margin: 0;
  padding: 16px 16px 7px;
}

.settings-stack > .client-section .section-title {
  color: #8e8e93;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.settings-stack > .client-section .field.field-row,
.settings-stack > .client-section .assistant-form-grid > .field:not(.field-checkbox),
.settings-stack > .client-section .assistant-form > .field:not(.field-checkbox),
.settings-stack > .client-section .quick-reply-form > .field,
.settings-stack > .client-section .inline-setting-form > .field {
  grid-template-columns: 100px minmax(0, 1fr);
  column-gap: 8px;
  min-height: 52px;
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.settings-stack > .client-section .field.field-row:hover,
.settings-stack > .client-section .assistant-form-grid > .field:hover,
.settings-stack > .client-section .assistant-form > .field:hover,
.settings-stack > .client-section .quick-reply-form > .field:hover,
.settings-stack > .client-section .inline-setting-form > .field:hover {
  background: rgba(0, 0, 0, 0.025);
}

.settings-stack > .client-section .field-label {
  color: #2f2f2f;
  font-size: 13px;
}

.settings-stack > .client-section input,
.settings-stack > .client-section select,
.settings-stack > .client-section textarea {
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #f7f7f8;
  font-size: 13.5px;
}

.settings-stack > .client-section input:focus,
.settings-stack > .client-section select:focus,
.settings-stack > .client-section textarea:focus {
  border-color: #0d0d0d;
  box-shadow: none;
}

@media (max-width: 1280px) {
  .settings-layout {
    padding-left: clamp(40px, 10vw, 120px);
    padding-right: clamp(40px, 10vw, 120px);
  }
}

@media (max-width: 900px) {
  .settings-layout {
    padding: 28px 20px 64px;
  }
}

@media (max-width: 680px) {
  .settings-layout {
    padding: 24px 14px 64px;
  }

  .settings-stack > .client-section .field.field-row,
  .settings-stack > .client-section .assistant-form-grid > .field:not(.field-checkbox),
  .settings-stack > .client-section .assistant-form > .field:not(.field-checkbox),
  .settings-stack > .client-section .quick-reply-form > .field,
  .settings-stack > .client-section .inline-setting-form > .field {
    grid-template-columns: 88px minmax(0, 1fr);
    padding-inline: 12px;
  }
}

/* Downloader-style settings surface: one setting per row, soft grouped
   cards, and the same restrained control geometry used by the reference UI. */
.settings-layout {
  width: min(880px, calc(100% - 48px));
  padding: 28px 0 80px;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.settings-stack > .client-section {
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #f4f4f5;
  box-shadow: none;
}

.settings-stack > .client-section > .section-title {
  margin: 0;
  padding: 15px 16px 8px;
  color: #8e8e93;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

.settings-stack > .client-section > .field-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}

.settings-stack > .client-section .field.field-row {
  display: grid;
  grid-template-columns: minmax(128px, 0.34fr) minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 52px;
  max-height: none;
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  background: transparent;
  box-sizing: border-box;
}

.settings-stack > .client-section .field.field-row:last-child {
  border-bottom: 0;
}

.settings-stack > .client-section .field.field-row:hover,
.settings-stack > .client-section .field.field-row:focus-within {
  background: rgba(0, 0, 0, 0.025);
}

.settings-stack > .client-section .field-label {
  color: #1e293b;
  font-size: 14px;
  font-weight: 500;
}

.settings-stack > .client-section .field-help {
  color: #8e8e93;
  font-size: 12px;
  line-height: 1.5;
}

.settings-stack > .client-section > .field-stack > .field-help {
  display: block;
  padding: 8px 16px 14px;
}

.settings-stack > .client-section .field.field-row input,
.settings-stack > .client-section .field.field-row select,
.settings-stack > .client-section .field.field-row .split input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #fff;
  font-size: 13.5px;
  box-sizing: border-box;
}

.settings-stack > .client-section .field.field-row input:focus,
.settings-stack > .client-section .field.field-row select:focus {
  border-color: #0d0d0d;
  box-shadow: none;
}

.settings-stack > .client-section .app-key-row {
  align-items: start;
}

.settings-stack > .client-section .app-key-setting,
.settings-stack > .client-section .app-key-control,
.settings-stack > .client-section .app-key-actions {
  min-width: 0;
}

.settings-stack > .client-section .app-key-setting {
  width: 100%;
}

.settings-stack > .client-section .app-key-actions {
  justify-content: flex-start;
}

.settings-stack > .client-section .section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px 8px;
}

.settings-stack > .client-section .section-head .section-title {
  padding: 0;
}

.settings-stack > .client-section .assistant-form,
.settings-stack > .client-section .quick-reply-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}

.settings-stack > .client-section .assistant-form-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-stack > .client-section .assistant-form-grid > .field,
.settings-stack > .client-section .assistant-form > .field,
.settings-stack > .client-section .quick-reply-form > .field {
  display: grid;
  grid-template-columns: minmax(128px, 0.34fr) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 52px;
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
}

.settings-stack > .client-section .assistant-form-grid > .field-checkbox,
.settings-stack > .client-section .assistant-form > .field-checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  width: auto;
  min-height: 52px;
  padding: 8px 16px;
}

.settings-stack > .client-section .assistant-form-grid > .field-checkbox span,
.settings-stack > .client-section .assistant-form > .field-checkbox span {
  white-space: nowrap;
}

.settings-stack > .client-section .assistant-form > .field:not(.field-checkbox) > textarea,
.settings-stack > .client-section .quick-reply-form > .field > textarea {
  min-height: 96px;
  padding-block: 9px;
  line-height: 1.55;
}

.settings-stack > .client-section .setting-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.settings-stack > .client-section .quick-replies-settings-list {
  margin: 0 16px 14px;
}

.settings-stack > .client-section #passwordForm {
  padding: 0;
}

.settings-stack > .client-section #passwordForm > .field {
  display: grid;
  grid-template-columns: minmax(128px, 0.34fr) minmax(0, 1fr);
  align-items: center;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.settings-stack > .client-section #passwordForm > .btn {
  align-self: flex-start;
  margin: 8px 16px 14px auto;
}

@media (max-width: 900px) {
  .settings-layout {
    width: min(100% - 32px, 880px);
    padding: 24px 0 64px;
  }
}

@media (max-width: 680px) {
  .settings-layout {
    width: calc(100% - 20px);
    padding: 20px 0 56px;
  }

  .settings-stack > .client-section .field.field-row,
  .settings-stack > .client-section .assistant-form-grid > .field,
  .settings-stack > .client-section .assistant-form > .field,
  .settings-stack > .client-section .quick-reply-form > .field,
  .settings-stack > .client-section #passwordForm > .field {
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
  }

  .settings-stack > .client-section .field.field-row {
    min-height: 82px;
  }

  .settings-stack > .client-section .section-head {
    display: block;
  }

  .settings-stack > .client-section .section-head .field-help {
    display: block;
    margin-top: 5px;
  }

  .settings-stack > .client-section .app-key-row {
    min-height: 150px;
  }
}
*/

/* Settings composition follows the downloader reference: each setting gets
   its own horizontal row, while the row group stays visually calm and airy. */
.settings-stack {
  gap: 18px;
  margin-top: 22px;
}

.settings-stack > .client-section {
  margin: 0;
  padding: 24px 26px 20px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(16, 24, 40, 0.08);
}

.settings-stack > .client-section .section-title {
  margin: 0 0 4px;
  color: #1f2937;
  font-size: 16px;
  font-weight: 700;
}

.settings-stack > .client-section .field-stack {
  gap: 0;
}

.settings-stack > .client-section .field.field-row {
  min-height: 62px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(16, 24, 40, 0.08);
  border-radius: 0;
}

.settings-stack > .client-section .field.field-row:last-child {
  border-bottom: 0;
}

.settings-stack > .client-section .field.field-row:hover {
  background: transparent;
}

.settings-stack > .client-section .field-help {
  color: #7b8798;
  font-size: 13px;
  line-height: 1.55;
}

.settings-stack > .client-section .section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 6px;
}

.settings-stack > .client-section .assistant-form,
.settings-stack > .client-section .quick-reply-form,
.settings-stack > .client-section .field-stack {
  display: flex;
  flex-direction: column;
}

.settings-stack > .client-section .assistant-form-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-stack > .client-section .assistant-form-grid > .field,
.settings-stack > .client-section .quick-reply-form > .field,
.settings-stack > .client-section .inline-setting-form > .field {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 62px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(16, 24, 40, 0.08);
}

.settings-stack > .client-section .assistant-form-grid > .field-checkbox {
  width: 100%;
  min-height: 62px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(16, 24, 40, 0.08);
}

.settings-stack > .client-section .assistant-form-grid > .field-checkbox span {
  white-space: normal;
}

.settings-stack > .client-section .quick-reply-form > .field:nth-of-type(2) {
  align-items: start;
}

.settings-stack > .client-section .quick-reply-form > .field:last-of-type,
.settings-stack > .client-section .inline-setting-form > .field:last-of-type {
  border-bottom: 0;
}

.settings-stack > .client-section .assistant-form > .field:not(.field-checkbox) {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 62px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(16, 24, 40, 0.08);
}

.settings-stack > .client-section .setting-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding-top: 12px;
}

.settings-stack > .client-section .inline-setting-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-stack > .client-section .inline-setting-form > .btn {
  align-self: flex-start;
  margin-top: 12px;
}

.settings-stack > .client-section .quick-replies-settings-list,
.settings-stack > .client-section #diagInfo {
  margin-top: 8px;
}

@media (max-width: 680px) {
  .settings-stack > .client-section {
    padding: 20px 18px 16px;
  }

  .settings-stack > .client-section .section-head {
    display: block;
  }

  .settings-stack > .client-section .assistant-form-grid > .field,
  .settings-stack > .client-section .assistant-form > .field:not(.field-checkbox),
  .settings-stack > .client-section .quick-reply-form > .field,
  .settings-stack > .client-section .inline-setting-form > .field {
    grid-template-columns: 1fr;
    gap: 7px;
    align-items: stretch;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  user-select: none;
}

/* Keep the session check invisible so an existing login never flashes the auth view. */
body.is-session-loading .app {
  visibility: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

input, textarea,
.msg .msg-body,
.thinking-content,
.sources-doc,
.sources-snippet {
  user-select: text;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* ── App shell ── */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100%;
  transition: grid-template-columns 0.42s var(--ease-out);
  background: var(--bg);
}

.app.is-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

/* ── Sidebar（ChatGPT 式灰侧栏） ── */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: var(--side-w);
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition:
    width 0.42s var(--ease-out),
    opacity 0.28s ease,
    transform 0.42s var(--ease-out);
  z-index: 30;
}

.app.is-collapsed .sidebar {
  width: 0;
  opacity: 0;
  border-right-color: transparent;
  pointer-events: none;
  transform: translateX(-8px);
}

.icon-round {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s var(--ease);
}

.icon-round:hover {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.icon-round:active {
  transform: scale(0.96);
}

.icon-round svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 10px 12px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.14) transparent;
}

.side-label {
  padding: 14px 12px 6px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  text-transform: none;
}

.side-label--top {
  padding-top: 8px;
}

/* Reuse downloader WebUI's search control contract: 36px height, 10px
   radius, and a quiet surface that fits the sidebar. */
.search.conversation-search {
  display: block;
  width: 100%;
  min-width: 0;
  height: 36px;
  margin: 0 0 10px;
  /* sidebar-scroll already provides 10px above; keep 10px below for equal breathing room. */
  box-sizing: border-box;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search.conversation-search:hover {
  border-color: rgba(0, 0, 0, 0.16);
  background: #fff;
}

.search.conversation-search:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.search.conversation-search::placeholder {
  color: var(--muted);
  opacity: 1;
}

.conv-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
  min-height: 38px;
  padding: 7px 8px 7px 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  transition: background 0.14s ease, color 0.14s ease;
}

.conv:hover {
  background: var(--bg-side-hover);
}

.conv.is-active {
  background: var(--bg-side-active);
  color: var(--ink);
  box-shadow: none;
  font-weight: var(--fw-semibold);
}

.conv__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.conv__del {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.conv:hover .conv__del,
.conv.is-active .conv__del {
  opacity: 1;
}

.conv__del:hover {
  background: rgba(194, 59, 46, 0.1);
  color: var(--danger);
}

.conv__del svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conv-empty {
  padding: 20px 10px;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: center;
  line-height: var(--lh-body);
}

.sidebar-foot {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  display: grid;
  gap: 2px;
  padding: 4px 10px 6px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, var(--bg-side) 18%);
}

/* Current-user account control: a solid main-site menu that opens upward. */
.sidebar-account-menu {
  position: absolute;
  right: 10px;
  bottom: calc(100% + 4px);
  left: 10px;
  z-index: 4;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-side);
  box-shadow: 0 14px 32px rgba(20, 26, 38, 0.14);
}

.sidebar-account-menu[hidden] {
  display: none !important;
}

.sidebar-account-menu__profile,
.sidebar-account-menu__settings,
.sidebar-account-trigger {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1.35;
  text-decoration: none;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}

.sidebar-account-menu__profile:hover,
.sidebar-account-menu__settings:hover,
.sidebar-account-trigger:hover {
  color: var(--ink);
  background: rgba(23, 105, 245, 0.055);
}

.sidebar-account-menu__profile:focus-visible,
.sidebar-account-menu__settings:focus-visible,
.sidebar-account-trigger:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 1px;
}

.sidebar-account-menu__profile {
  font-weight: var(--fw-semibold);
}

.sidebar-account-menu__settings {
  margin-top: 2px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 9px 9px;
}

.sidebar-account-menu__settings svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-account-avatar {
  display: block;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  overflow: hidden;
  border-radius: 50%;
  background: #e8e9ec;
}

.sidebar-account-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.sidebar-account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account-trigger {
  min-height: 36px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  transition: background 0.14s ease, color 0.14s;
}

.sidebar-foot .side-link,
.sidebar-foot .side-link:hover,
.sidebar-foot .side-link:focus,
.sidebar-foot .side-link:active,
.sidebar-foot .side-link:visited {
  border-bottom: 0 !important;
  text-decoration: none !important;
  text-decoration-line: none !important;
}

.side-link:hover,
.side-link.is-active {
  background: var(--bg-side-active);
  color: var(--ink);
  box-shadow: none;
}

.side-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Main ── */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: transparent;
}

/* sidebar-fab-align-v1: 42px control centered in the desktop 70px chat bar. */
.sidebar-fab {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 20;
  width: 42px;
  height: 42px;
  box-shadow: var(--shadow-sm);
  background: #fff;
  border-color: var(--line);
}

.sidebar-fab svg,
.kb-page-bar .icon-round svg {
  width: 21px;
  height: 21px;
}

.sidebar-fab.menu-fab {
  left: 62px;
}

/* 对话页顶栏：高度与 fab 对齐，标题居中 */
.chat-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 58px;
  min-height: 58px;
  padding: 0 56px; /* 左右对称，避免标题视觉偏移；左侧给 fab 留空 */
  border-bottom: 1px solid transparent;
  box-sizing: border-box;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.app:not(.is-collapsed) .chat-bar {
  padding-left: 56px;
  padding-right: 56px;
}

.top-title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(62vw, 28rem);
  letter-spacing: 0;
  text-align: center;
}

.top-title.is-hidden {
  display: none;
}

/* 非对话页隐藏对话标题行 */
.app.is-page-mode .chat-bar {
  display: none;
}

/* Settings uses the sidebar as its navigation; keep its heading clear of the
   floating chat collapse control. */
.app.is-page-mode .sidebar-fab {
  display: none !important;
}

/* 知识库页：隐藏悬浮按钮，改用顶栏一行 */
.app.is-knowledge-mode .sidebar-fab {
  display: none !important;
}

/* 仅占知识库中间列宽度 */
.kb-page-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  min-height: 56px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-side);
  box-sizing: border-box;
}

.kb-page-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-page-bar .icon-round {
  width: 42px;
  height: 42px;
  background: #fff;
  border-color: var(--line);
}

.kb-page-bar .icon-round:hover {
  background: #fff;
}

.model-inline {
  position: relative;
}

.model-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 200px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.2s var(--ease-spring);
}

.model-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.model-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}

.model-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(260px, 72vw);
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.14) transparent;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: pop 0.22s var(--ease-spring);
  isolation: isolate;
}

.model-panel::-webkit-scrollbar {
  width: 8px;
}

.model-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.model-panel button {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  text-align: left;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  background: transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.model-panel button:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
  z-index: 1;
}

.model-panel button.is-on {
  background: rgba(0, 0, 0, 0.09);
  color: var(--ink);
  font-weight: var(--fw-semibold);
}

.model-panel button + button {
  margin-top: 2px;
}

/* ── Views ── */
.view {
  flex: 1 1 auto;
  min-height: 0;
  height: 0; /* force flex child to take remaining height for nested scroll */
  display: none;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.view.is-active {
  display: flex !important;
  animation: viewIn 0.42s var(--ease-out) both;
}

/* Keep the original message entry motion, but do not animate the chat view
   itself; otherwise refresh/navigation makes every bubble appear twice. */
.view[data-view="chat"].is-active {
  animation: none !important;
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes msgInUser {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes msgInAsst {
  from { opacity: 0; transform: translateY(14px); filter: blur(1.5px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulseSoft {
  0%, 100% { opacity: 0.35; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes cursorBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes barRun {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(220%); }
}

/* ── Chat thread ── */
.thread {
  flex: 1 1 auto;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.thread::-webkit-scrollbar { width: 8px; }
.thread::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.welcome {
  display: grid;
  place-items: center;
  min-height: calc(100% - 20px);
  padding: 48px 20px 140px;
}

.welcome[hidden] { display: none !important; }

.chat-empty {
  width: min(var(--content-w), 100%);
  margin: 0 auto;
  padding: 28px var(--content-gutter) 18px;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  text-align: center;
}

.chat-empty[hidden] { display: none !important; }

.welcome-card {
  width: min(var(--content-w), 100%);
  text-align: center;
  padding: 8px 4px;
}

.welcome-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  animation: rise 0.55s var(--ease-out) both;
}

.welcome-card h2 {
  margin: 0 0 32px;
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  line-height: var(--lh-tight);
  color: var(--ink);
  animation: rise 0.6s var(--ease-out) 0.06s both;
}

.suggests {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  max-width: 560px;
  margin: 0 auto;
}

.suggests--2,
.suggests--4 {
  max-width: 560px;
  margin: 0 auto;
}

.suggests button {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  transition:
    transform 0.28s var(--ease-spring),
    box-shadow 0.28s var(--ease-out),
    border-color 0.18s ease,
    background 0.18s ease;
  animation: rise 0.55s var(--ease-out) both;
}

.suggests button:nth-child(1) { animation-delay: 0.1s; }
.suggests button:nth-child(2) { animation-delay: 0.16s; }
.suggests button:nth-child(3) { animation-delay: 0.22s; }
.suggests button:nth-child(4) { animation-delay: 0.28s; }

.suggests button:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: rgba(0, 0, 0, 0.12);
  background: #fafafa;
  box-shadow: var(--shadow-md);
}

.suggests button:active {
  transform: translateY(-1px) scale(0.995);
}

.suggests strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}

.suggests span {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

/* Messages：同宽内容栏（ChatGPT 文档流） */
.messages {
  width: min(var(--content-w), 100%);
  margin: 0 auto;
  padding: 12px 20px 28px;
}

/* Base messages stay static. Only the first authoritative timeline render
   adds msg-enter; later HTTP/WebSocket rebuilds leave the history in place. */
.msg {
  width: 100%;
  padding: 18px 0;
  animation: none;
}

.messages.is-message-static .msg {
  animation: none !important;
}

.msg.msg-enter {
  will-change: opacity, transform;
  animation: msgInAsst 0.48s var(--ease-out) both;
}

.msg--user {
  display: flex;
  justify-content: flex-end;
}

.msg--user.msg-enter {
  animation-name: msgInUser;
}

.msg--user .msg-col {
  width: 100%;
  max-width: min(85%, 36rem);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg--user .msg-body {
  width: fit-content;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--user-bg);
  font-size: var(--fs-lg);
  line-height: var(--lh-prose);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: none;
  border: 0;
}

.msg--assistant {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  padding: 0;
  box-shadow: 0 1px 3px rgba(20, 18, 14, 0.08), inset 0 0 0 1px rgba(20, 18, 14, 0.08);
  margin-top: 2px;
  flex-shrink: 0;
}

.msg-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.msg-col {
  min-width: 0;
  width: 100%;
}

.msg-role {
  margin: 0 0 6px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink);
  letter-spacing: 0;
}

.msg-body {
  font-size: var(--fs-lg);
  line-height: 1.75;
  color: var(--ink);
  word-break: break-word;
  user-select: text;
}

.msg-body.md > :first-child { margin-top: 0; }
.msg-body.md > :last-child { margin-bottom: 0; }
.msg-body.md p { margin: 0 0 0.7em; }
.msg-body.md p:last-child { margin-bottom: 0; }
.msg-body.md h1, .msg-body.md h2, .msg-body.md h3 {
  margin: 0.9em 0 0.35em;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}
.msg-body.md h1 { font-size: 1.15em; }
.msg-body.md h2 { font-size: 1.08em; }
.msg-body.md h3 { font-size: 1.02em; }
.msg-body.md ul, .msg-body.md ol {
  margin: 0.35em 0 0.7em;
  padding-left: 1.35em;
}
.msg-body.md li { margin: 0.2em 0; }
.msg-body.md strong { font-weight: var(--fw-semibold); }
.msg-body.md code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.06);
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.msg-body.md pre {
  margin: 0.55em 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.05);
  overflow-x: auto;
}
.msg-body.md pre code { padding: 0; background: none; }
.msg-body.md blockquote {
  margin: 0.45em 0;
  padding-left: 12px;
  border-left: 3px solid rgba(0, 0, 0, 0.14);
  color: var(--ink-soft);
}
.msg-body.md .md-table-wrap {
  max-width: 100%;
  margin: 0.65em 0 0.85em;
  overflow-x: auto;
  border: 1px solid rgba(30, 35, 48, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  scrollbar-width: thin;
}
.msg-body.md table {
  width: 100%;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95em;
  line-height: 1.55;
}
.msg-body.md th,
.msg-body.md td {
  padding: 9px 11px;
  border-right: 1px solid rgba(30, 35, 48, 0.08);
  border-bottom: 1px solid rgba(30, 35, 48, 0.08);
  vertical-align: top;
  white-space: normal;
}
.msg-body.md th {
  font-weight: var(--fw-semibold);
  background: rgba(30, 35, 48, 0.045);
  color: var(--ink);
}
.msg-body.md th:last-child,
.msg-body.md td:last-child { border-right: 0; }
.msg-body.md tbody tr:last-child td { border-bottom: 0; }
.msg-body.md a {
  color: var(--accent-ink);
  text-underline-offset: 2px;
}

/* 流式输出不显示光标 */
.msg.is-stream .msg-body::after {
  content: none;
}

/* 等待首包：三点动画 + 秒数 */
.msg-wait {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 10px;
  min-height: 22px;
  color: var(--muted);
  font-size: var(--fs-sm);
  user-select: none;
  white-space: nowrap;
}

.msg-wait-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.msg-wait-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: waitDot 1.1s ease-in-out infinite;
}

.msg-wait-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.msg-wait-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

.msg-wait-label {
  color: var(--muted);
}

.msg-wait-sec {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  opacity: 0.85;
  min-width: 2.6em;
}

@keyframes waitDot {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* 旧进度条保留类名兼容 */
.msg-progress {
  position: relative;
  height: 2px;
  width: min(160px, 40%);
  margin: 0 0 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
  animation: rise 0.35s var(--ease-out) both;
}

.msg-progress > i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #111, transparent);
  animation: barRun 1.15s var(--ease) infinite;
}

/* ── 思考 / 来源：轻折叠（ChatGPT 感） ── */
.thinking-panel,
.sources-panel {
  position: relative;
  z-index: 1;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}

.sources-panel {
  margin: 14px 0 0;
  padding: 2px;
  border-radius: 14px;
  background: #f7f7f8;
  border: 1px solid var(--line);
}

.thinking-panel[hidden],
.sources-panel[hidden] {
  display: none !important;
}

.thinking-panel.is-live .fold-title::after {
  content: none;
}

.fold-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s var(--ease);
}

.fold-head:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink-soft);
}

.fold-title {
  flex: 1 1 auto;
  min-width: 0;
}

.fold-chevron {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition:
    transform 0.32s var(--ease-spring),
    background 0.18s ease,
    color 0.18s ease;
}

.fold-chevron svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.is-expanded > .fold-head .fold-chevron {
  transform: rotate(180deg);
  color: var(--ink-soft);
}

.fold-body {
  position: relative;
  overflow: hidden;
  margin: 0;
  border-radius: 10px;
  max-height: 4.8em;
  opacity: 0.9;
  transition:
    max-height 0.38s var(--ease-out),
    opacity 0.24s ease;
}

.is-collapsed {
  cursor: pointer;
}

.is-collapsed > .fold-body {
  max-height: 4.8em;
  cursor: pointer;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 100%);
}

.is-collapsed > .fold-body::after {
  display: none;
}

.is-expanded > .fold-body {
  max-height: 280px;
  opacity: 1;
  cursor: default;
  -webkit-mask-image: none;
  mask-image: none;
}

.is-expanded > .fold-body::after {
  display: none;
}

.thinking-panel.is-expanded > .fold-body {
  max-height: 220px;
  overflow: hidden;
}

.sources-panel.is-expanded > .fold-body {
  max-height: 380px;
  overflow: hidden;
}

.sources-item.is-expanded > .fold-body {
  max-height: 180px;
  overflow: hidden;
}

.thinking-content,
.sources-list,
.sources-item-body {
  max-height: 100%;
  padding: 2px 8px 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.is-expanded > .fold-body > .thinking-content,
.is-expanded > .fold-body > .sources-list,
.is-expanded > .fold-body > .sources-item-body {
  max-height: inherit;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.thinking-content.is-placeholder {
  color: var(--muted);
}

.sources-list {
  display: grid;
  gap: 4px;
  padding: 2px 6px 8px;
}

.sources-item {
  display: grid;
  gap: 0;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  transition: background 0.16s ease;
}

.sources-item:hover {
  background: rgba(255, 255, 255, 0.7);
}

.sources-item .fold-head {
  min-height: 34px;
  padding: 6px 8px;
  color: var(--ink-soft);
}

.sources-item .fold-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}

.sources-item .fold-body {
  margin: 0 4px 4px;
}

.sources-item-body {
  display: grid;
  gap: 4px;
  padding: 0 8px 8px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  line-height: var(--lh-prose);
  white-space: normal;
}

.sources-item.is-collapsed .sources-item-body {
  overflow: hidden;
  pointer-events: none;
}

.sources-doc {
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
}

.sources-snippet {
  margin: 0;
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  line-height: var(--lh-prose);
  white-space: pre-wrap;
}

.sources-panel.sources-enter {
  opacity: 0;
  transform: translate3d(0, 12px, 0) scale(0.98);
  filter: blur(2px);
}

.sources-panel.sources-enter-active {
  opacity: 1;
  transform: none;
  filter: none;
  transition:
    opacity 0.48s var(--ease-out),
    transform 0.52s var(--ease-out),
    filter 0.4s ease;
}

@media (prefers-reduced-motion: reduce) {
  .fold-body,
  .fold-chevron,
  .fold-head,
  .sources-panel.sources-enter-active,
  .msg,
  .view.is-active,
  .msg-progress > i {
    animation: none !important;
    transition: none !important;
  }
}

/* 操作：纯图标 */
.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.22s var(--ease-out);
}

.msg:hover .msg-actions,
.msg.actions-on .msg-actions {
  opacity: 1;
  transform: none;
}

.msg-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0;
  line-height: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.18s var(--ease-spring);
}

.msg-actions button:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
  transform: scale(1.06);
}

.msg-actions button:active {
  transform: scale(0.94);
}

.msg-actions button.is-ok {
  color: #1a7f37;
}

.msg-actions button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Jump + composer */
.jump {
  position: absolute;
  left: 50%;
  bottom: calc(34px + 118px);
  z-index: 9;
  transform: translateX(-50%);
  height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  transition: opacity 0.2s, transform 0.22s var(--ease);
  pointer-events: auto;
}

.jump[hidden] {
  display: block !important;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
}

.dock {
  flex-shrink: 0;
  padding: 0 16px 12px;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.72) 28%, var(--bg) 62%);
  z-index: 10;
}

.composer {
  width: min(var(--content-w), 100%);
  margin: 0 auto;
}

.composer-shell {
  position: relative;
  padding: 12px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #ffffff;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.02),
    0 8px 28px rgba(0, 0, 0, 0.06);
  transition:
    border-color 0.22s ease,
    box-shadow 0.32s var(--ease-out),
    transform 0.32s var(--ease-out);
}

.composer-shell:focus-within {
  border-color: rgba(0, 0, 0, 0.16);
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.04),
    0 12px 36px rgba(0, 0, 0, 0.09);
  transform: translateY(-1px);
}

.composer-shell textarea {
  width: 100%;
  min-height: 24px;
  max-height: 180px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: var(--fs-lg);
  line-height: var(--lh-body);
  padding: 0 2px;
}

/* composer-shortcut-hint-v1: keep keyboard guidance subtle and aligned with the text baseline. */
.composer-shell textarea::placeholder {
  color: #a5aabd;
  opacity: 1;
  letter-spacing: .01em;
}

.composer-shell textarea::-webkit-scrollbar { width: 6px; }
.composer-shell textarea::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 99px;
}

.composer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 10px;
}

.composer-tools {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.tool-chip--add {
  width: 30px;
  padding-inline: 0;
  justify-content: center;
}

.tool-chip--add svg {
  width: 15px;
  height: 15px;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.2s var(--ease-spring);
}

.tool-chip svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.tool-chip:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}

.tool-chip.is-on {
  background: rgba(0, 0, 0, 0.07);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  font-weight: var(--fw-semibold);
  transform: scale(1.03);
}

.tool-chip.is-locked {
  cursor: default;
}

.tool-chip.is-locked::after {
  display: none !important;
}

.tool-chip:disabled {
  opacity: 0.62;
}

.tool-chip.is-on:disabled {
  opacity: 1;
}

.model-inline {
  flex-shrink: 0;
}

.send {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0d0d0d;
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition:
    transform 0.22s var(--ease-spring),
    background 0.15s,
    opacity 0.15s,
    box-shadow 0.22s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
}

.send:not(:disabled):hover {
  transform: scale(1.08);
  background: #1a1a1a;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.send:not(:disabled):active {
  transform: scale(0.94);
}

.send:disabled {
  opacity: 0.28;
  box-shadow: none;
}

.send svg {
  position: absolute;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.15s, transform 0.15s;
}

.send .i-stop {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: none;
  opacity: 0;
  transform: scale(0.5);
}

.send.is-stop {
  background: var(--danger);
  box-shadow: 0 8px 18px rgba(194, 59, 46, 0.28);
  opacity: 1 !important;
  cursor: pointer;
}

.send.is-stop:hover {
  background: #a83228;
}

.send.is-stop .i-up {
  opacity: 0;
  transform: scale(0.5);
}

.send.is-stop .i-stop {
  opacity: 1;
  transform: scale(1);
}

.disclaimer {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-2xs);
  letter-spacing: 0.01em;
  opacity: 0.85;
}

/* ── Settings / Knowledge pages ── */
.page-scroll {
  flex: 1 1 auto;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.14) transparent;
  touch-action: pan-y;
  background: var(--bg);
}

.page-scroll::-webkit-scrollbar {
  width: 8px;
}

.page-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 12px 22px 80px;
}

/* ── Knowledge / Settings：与对话页同色（纯白，无暖黄底） ── */
.view[data-view="knowledge"].is-active {
  overflow: hidden;
  display: flex !important;
  flex-direction: column;
  background: var(--bg);
}

.view[data-view="settings"].is-active {
  background: var(--bg);
}

.kb-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.kb-mid {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border-right: 1px solid var(--line);
  background: var(--bg-side);
  width: 232px;
  box-shadow: none;
}

.kb-sidebar {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 10px 14px;
  overflow: hidden;
}

.import-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  align-self: center;
  height: 38px;
}

.import-part-select {
  min-width: 156px;
  max-width: 200px;
  height: 38px !important;
  line-height: 38px !important;
  padding: 0 32px 0 12px !important;
  font-size: var(--fs-md) !important;
  display: inline-block;
  vertical-align: middle;
}

.kb-side-brand {
  padding: 4px 10px 12px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.kb-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ink-soft);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  text-align: left;
  border: 1px solid transparent;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.kb-nav svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0.88;
}

.kb-nav:hover {
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}

.kb-nav.is-on {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border-color: rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 16px rgba(0, 0, 0, 0.05);
  font-weight: var(--fw-semibold);
}

.kb-nav.is-on svg {
  opacity: 1;
}

.kb-side-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

.kb-side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 8px;
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kb-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--ink-soft);
  font-size: var(--fs-lg);
  line-height: 1;
  transition: background 0.12s, transform 0.12s;
}

.kb-mini:hover {
  background: #fff;
  transform: scale(1.05);
}

.kb-side-foot {
  padding: 10px 6px 0;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.kb-mini-btn {
  width: 100%;
  height: 34px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.kb-mini-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.kb-panel[hidden] {
  display: none !important;
}

.kb-panel.is-on {
  display: block;
}

.part-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  padding: 0 2px;
  min-height: 0;
  flex: 1;
}

.part-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px;
  min-height: 42px;
  padding: 7px 8px 7px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--ink-soft);
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.part-item:hover {
  background: rgba(255, 255, 255, 0.45);
}

.part-item.is-on {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 14px rgba(0, 0, 0, 0.05);
  color: var(--ink);
  font-weight: var(--fw-semibold);
}

.part-item .part-main {
  display: grid;
  gap: 1px;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.part-item .part-main strong {
  font-size: var(--fs-sm);
  font-weight: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-item .part-main small {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.part-item .part-ops {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

.part-item:hover .part-ops,
.part-item.is-on .part-ops {
  opacity: 1;
}

.part-item .part-ops button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.part-item .part-ops button:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--ink);
}

.part-item .part-ops button.danger:hover {
  background: rgba(194, 59, 46, 0.1);
  color: var(--danger);
}

.part-item .part-ops svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.kb-content {
  background: var(--bg);
  min-width: 0;
  height: 100%;
}

.kb-main {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 22px 32px 72px;
  animation: pageInSoft 0.35s var(--ease) both;
}

@keyframes pageInSoft {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.kb-hero,
.settings-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
}

.kb-hero h1,
.settings-hero h1 {
  margin: 0 0 6px;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: 0;
  line-height: var(--lh-tight);
}

.kb-hero p,
.settings-hero p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  max-width: 36em;
}

.kb-hero-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* 无大背景卡片，精致分区 */
.client-block,
.client-section {
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.client-section {
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.client-section:first-child {
  border-top: 0;
  padding-top: 12px;
}

.client-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.client-block-head.is-actions {
  align-items: center;
  min-height: 48px;
}

.client-block-head.is-actions .client-block-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 38px;
}

.client-block-copy h3 {
  margin: 0 0 4px;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  line-height: var(--lh-tight);
  color: var(--ink);
}

.client-block-copy p,
.client-block-head p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

/* 分区标题：区块级标签（13 / semibold） */
.section-title {
  margin: 0 0 14px;
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  border: 0;
  line-height: var(--lh-tight);
}

/* 标题行 + 右侧操作：与按钮同高垂直居中 */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 36px;
}

.section-head .section-title {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  align-items: center;
  min-height: 36px;
  line-height: 1;
}

.section-head .btn,
.section-head .btn.compact {
  height: 36px;
  padding: 0 13px;
  flex-shrink: 0;
  font-size: var(--fs-xs);
  border-radius: 9px;
}

/* 通栏字段：标签左、控件右 */
.field-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field.field-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 0;
  min-height: 44px;
  padding: 4px 0;
  border-radius: 10px;
  transition: background 0.12s ease;
}

.field.field-row:hover {
  background: transparent;
}

.field.field-row .field-label {
  margin: 0;
  padding-left: 2px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-soft);
  line-height: var(--lh-snug);
}

.field.field-row input,
.field.field-row select,
.field.field-row .split {
  width: 100%;
}

.field.field-row input,
.field.field-row .split input {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.88);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field.field-row input:hover,
.field.field-row .split input:hover {
  border-color: rgba(0, 0, 0, 0.16);
  background: #fff;
}

.field.field-row input:focus,
.field.field-row .split input:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
  outline: none;
}

/* 行内按钮（重建索引等）与输入框同高、左对齐 */
.field.field-row > .btn {
  justify-self: start;
  height: 40px;
  min-width: 96px;
}

.split.grow {
  width: 100%;
}

/* 知识库 / 设置：统一控件高度与圆角 */
.kb-main .btn,
.settings-layout .btn {
  height: 38px;
  border-radius: 10px;
  font-size: var(--fs-sm);
}

.kb-main .btn.compact,
.settings-layout .btn.compact {
  height: 40px;
}

/* section-head 内按钮高度优先（覆盖 compact 40px） */
.settings-layout .section-head .btn,
.settings-layout .section-head .btn.compact {
  height: 36px;
  font-size: var(--fs-xs);
}

.client-block-head .btn,
.import-actions .btn {
  height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
}

/* ── 统一下拉选择栏 ── */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.92);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6963' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-size: 14px 14px;
  background-repeat: no-repeat;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 40px;
  vertical-align: middle;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
  cursor: pointer;
}

select:hover {
  border-color: rgba(0, 0, 0, 0.18);
  background-color: #fff;
}

select:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.28);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
  background-color: #fff;
}

select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: rgba(0, 0, 0, 0.04);
}

/* field 内 select 与 input 同规格（压过后面通用 .field select） */
.field select,
.field.field-row select {
  height: 40px;
  line-height: 40px;
  padding: 0 34px 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background-color: rgba(255, 255, 255, 0.88);
  font-size: var(--fs-md);
}

.field select:hover,
.field.field-row select:hover {
  border-color: rgba(0, 0, 0, 0.16);
  background-color: #fff;
}

.field select:focus,
.field.field-row select:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

/* 文档行内小下拉 */
.doc-ops select {
  height: 32px;
  line-height: 32px;
  padding: 0 26px 0 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background-position: right 8px center;
  background-size: 12px 12px;
  max-width: 136px;
  box-shadow: none;
}

/* 联网方式：轻量选项格，非大卡片 */
.net-squares {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.net-square {
  aspect-ratio: auto;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.35);
  text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease);
}

.net-square strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
}

.net-square span {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-tight);
}

.net-square:hover {
  border-color: rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.7);
}

.net-square.is-on {
  border-color: rgba(0, 0, 0, 0.36);
  background: rgba(0, 0, 0, 0.06);
}

.net-square.is-on strong {
  color: var(--ink);
}

input.is-locked,
textarea.is-locked {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.04) !important;
  cursor: default;
  user-select: text;
}

input.is-locked:focus,
textarea.is-locked:focus {
  border-color: var(--line) !important;
  box-shadow: none !important;
}

/* 诊断：与上方 field-row 完全同一套网格 / 控件高度 / 边框色 */
.diag-list,
#diagInfo.field-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

#diagInfo .field.field-row,
.diag-list .field.field-row {
  cursor: default;
}

#diagInfo .field.field-row:hover,
.diag-list .field.field-row:hover {
  background: transparent;
}

/* 值区外观对齐只读 input（白底 + 同边框），非灰色卡片 */
#diagInfo .field-value,
.diag-list .field-value {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-soft);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  word-break: break-all;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-bar input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.search-bar input:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.16);
}

.search-bar input:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.doc-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 10px;
  border-radius: 10px;
  border: 0;
  border-bottom: 0;
  background: transparent;
  animation: rise 0.28s var(--ease) both;
  transition: background 0.12s ease;
}

.doc-row:hover {
  background: rgba(0, 0, 0, 0.035);
}

.doc-row:last-child {
  border-bottom: 0;
}

.doc-row strong {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.doc-ops {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.doc-ops button.icon-del {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  display: grid;
  place-items: center;
}

.doc-ops button.icon-del svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.doc-ops button.icon-del:hover {
  background: rgba(194, 59, 46, 0.1);
  color: var(--danger);
}

.empty-docs {
  padding: 48px 12px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  border: 0;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.025);
}

/* Settings layout — 客户端通栏 */
.settings-layout {
  width: min(700px, 100%);
  margin: 0 auto;
  padding: 22px 32px 72px;
  animation: pageInSoft 0.35s var(--ease) both;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 10px;
}

.settings-hero {
  padding-bottom: 10px;
  margin-bottom: 2px;
}

/* 行内操作按钮统一尺寸（显示 / 测试连接 / 检查更新旁） */
.split.grow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.split.grow input {
  flex: 1;
  min-width: 0;
}

.split.grow .btn.compact {
  height: 40px;
  padding: 0 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.prompt-area {
  width: 100%;
  min-height: 200px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  line-height: var(--lh-prose);
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.prompt-area.no-resize {
  resize: none;
}

.prompt-area:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.16);
}

.prompt-area:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.toggle.compact {
  padding: 8px 10px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
}

.toggle.compact:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* 上传区：轻虚线框，不是大卡片 */
.upload-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  border: 1px dashed rgba(0, 0, 0, 0.16);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.015);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.upload-zone:hover,
.upload-zone.is-drag {
  border-color: rgba(0, 0, 0, 0.28);
  background: rgba(0, 0, 0, 0.04);
  box-shadow: none;
}

.upload-zone:focus-visible {
  outline: none;
  border-color: rgba(0, 0, 0, 0.32);
  background: rgba(0, 0, 0, 0.04);
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.06);
  border: 0;
  flex-shrink: 0;
  color: var(--ink-soft);
}

.upload-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.upload-copy strong {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}

.upload-copy span {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}



.back {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.back:hover { color: var(--ink); }

.page-hero h1 {
  margin: 0 0 6px;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: 0;
  line-height: var(--lh-tight);
}

.page-hero p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}

.page-hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-hero-row h1 {
  margin: 0;
}

.settings-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 8px;
  padding: 10px 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

.settings-nav a {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.settings-nav a:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: #fff;
}

.sec {
  margin-top: 8px;
  padding: 22px 0 8px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 72px;
  animation: rise 0.4s var(--ease) both;
}

.sec:first-of-type {
  border-top: 0;
}

.sec-head {
  margin-bottom: 16px;
}

.sec-head.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sec-head h2 {
  margin: 0 0 6px;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  line-height: var(--lh-tight);
}

.sec-head p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-body);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-soft);
  line-height: var(--lh-snug);
}

.field-help {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: var(--lh-snug);
}

.field input,
.field textarea,
.split input {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.88);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

/* select 不走 background 简写，避免冲掉箭头图标 */
.field select {
  width: 100%;
  outline: none;
}

.field input,
.split input {
  height: 40px;
  padding: 0 12px;
}

.field textarea {
  min-height: 180px;
  padding: 12px 14px;
  line-height: var(--lh-body);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
  resize: vertical;
}

.field textarea::-webkit-scrollbar { width: 6px; }
.field textarea::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 99px;
}

.field input:focus,
.field textarea:focus,
.split input:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.split {
  display: flex;
  gap: 8px;
}

.split input { flex: 1; }

.choice-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.choice {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.18s var(--ease);
}

.choice strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.choice span {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

.choice:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.choice.is-on {
  border-color: rgba(0, 0, 0, 0.28);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.choice.is-on strong {
  color: var(--accent-ink);
}

.weights {
  margin: 4px 0 14px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.weights-title {
  margin-bottom: 10px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink-soft);
}

.toggle-block {
  display: grid;
  gap: 10px;
  margin: 8px 0 14px;
}

.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  position: relative;
  transition: background 0.2s ease;
  margin-top: 2px;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s var(--ease);
}

.toggle input:checked + .toggle-ui {
  background: #1c1b18;
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(16px);
}

.toggle-text {
  display: grid;
  gap: 2px;
}

.toggle-text strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.toggle-text em {
  font-style: normal;
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  transition: transform 0.15s var(--ease), background 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.btn.primary {
  background: linear-gradient(180deg, #2a2926 0%, #1c1b18 100%);
  color: #faf8f4;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.14);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 8px 18px rgba(0, 0, 0, 0.18);
}

.btn.ghost {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.btn.ghost:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.1);
}

.btn.compact {
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
}

.btn.primary.danger {
  background: linear-gradient(180deg, #d64a3d 0%, #b83328 100%);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 8px 18px rgba(194, 59, 46, 0.22);
}

.btn.primary.danger:hover {
  background: linear-gradient(180deg, #c84236 0%, #a52e25 100%);
}

.text-btn {
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  transition: color 0.12s, background 0.12s;
}

.text-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}

.list {
  display: grid;
  gap: 8px;
  margin: 10px 0 4px;
}

.list-item {
  padding: 12px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  box-shadow: none;
  animation: rise 0.3s var(--ease) both;
  transition: background 0.12s ease;
}

.list-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item strong { font-weight: var(--fw-semibold); }
.list-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.result-line {
  margin: 4px 0;
  font-size: var(--fs-sm);
  color: var(--accent-ink);
  font-weight: var(--fw-medium);
  min-height: 1.2em;
}

.diag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.diag-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.diag-card em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-bottom: 4px;
}

.diag-card strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  word-break: break-all;
}

.log {
  margin: 10px 0 0;
  padding: 14px 16px;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  border-radius: 12px;
  background: linear-gradient(180deg, #23221f 0%, #1c1b18 100%);
  color: #e8e4dc;
  font-size: var(--fs-xs);
  line-height: var(--lh-body);
  white-space: pre-wrap;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.log::-webkit-scrollbar { width: 6px; }
.log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
}

/* Toast / scrim */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
}

.scrim[hidden] { display: none !important; }

.context-menu {
  position: fixed;
  z-index: 86;
  min-width: 148px;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(4px) scale(0.985);
  transform-origin: top left;
  transition:
    opacity 0.16s var(--ease-out),
    transform 0.18s var(--ease-out);
  user-select: none;
}

.context-menu.is-on {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.context-menu[hidden] {
  display: none;
}

/* display:flex 会盖掉原生 [hidden]，必须强制隐藏 */
.context-menu button[hidden],
.context-menu button.is-hidden {
  display: none !important;
}

.context-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-align: left;
  transition:
    background 0.14s ease,
    color 0.14s ease,
    transform 0.14s var(--ease);
}

.context-menu button:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.055);
}

.context-menu button:active {
  transform: scale(0.985);
}

.ui-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.ui-modal-layer[hidden] {
  display: none !important;
}

.ui-modal-layer.is-on {
  pointer-events: auto;
}

.ui-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition:
    opacity 0.28s var(--ease-out),
    backdrop-filter 0.34s var(--ease-out),
    -webkit-backdrop-filter 0.34s var(--ease-out);
}

.ui-modal-layer.is-on .ui-modal-backdrop {
  opacity: 1;
}

.ui-modal-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.965);
  opacity: 0;
  filter: blur(2px);
  transition:
    transform 0.36s var(--ease-spring),
    opacity 0.22s ease,
    filter 0.28s ease;
}

.ui-modal-layer.is-on .ui-modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
  filter: none;
}

.ui-modal-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--ink);
  background: #f4f4f4;
  border: 1px solid var(--line);
}

.ui-modal-icon.is-danger {
  color: var(--danger);
  background: rgba(194, 59, 46, 0.08);
  border-color: rgba(194, 59, 46, 0.16);
}

.ui-modal-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-modal-copy {
  min-width: 0;
}

.ui-modal-copy h2 {
  margin: 1px 0 5px;
  color: var(--ink);
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: 0;
}

.ui-modal-copy p {
    margin: 0;
    color: var(--muted);
    font-size: var(--fs-sm);
    line-height: var(--lh-snug);
    overflow-wrap: anywhere;
    white-space: pre-line;
    max-height: min(44vh, 360px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ui-modal-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.ui-modal-field[hidden] {
  display: none !important;
}

.ui-modal-field span {
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.ui-modal-field input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: var(--fs-md);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.ui-modal-field input:focus {
  border-color: rgba(0, 0, 0, 0.24);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

.ui-modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 4px;
}

.ui-modal-actions .btn {
  min-width: 82px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 60;
  transform: translateX(-50%) translateY(12px);
  max-width: min(420px, calc(100% - 32px));
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #faf8f4;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.26s var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mobile-only { display: none; }

/* Responsive */
@media (max-width: 900px) {
  .app,
  .app.is-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw) !important;
    opacity: 1 !important;
    transform: translateX(-105%);
    pointer-events: auto !important;
    box-shadow: var(--shadow-lg);
    transition: transform 0.32s var(--ease);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .app.is-collapsed .sidebar {
    width: min(300px, 86vw) !important;
  }

  .mobile-only { display: grid; }

  .sidebar-fab:not(.menu-fab) {
    display: none !important;
  }

  .chat-bar {
    padding-left: 56px;
  }

  .suggests,
  .suggests--2,
  .grid-2,
  .grid-3,
  .diag-grid,
  .net-squares {
    grid-template-columns: 1fr;
  }

  .net-square {
    min-height: 64px;
  }

  .app.is-knowledge-mode .sidebar-fab.menu-fab {
    display: grid !important;
    position: static;
  }

  .kb-page-bar {
    gap: 10px;
  }

  .kb-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .kb-mid {
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .kb-sidebar {
    height: auto;
  }

  .import-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .import-part-select {
    flex: 1;
    min-width: 120px;
    max-width: none;
  }

  .kb-side-block {
    max-height: 150px;
  }

  .kb-hero,
  .settings-hero {
    flex-direction: column;
  }

  .field.field-row {
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
  }

  .upload-zone {
    flex-direction: column;
    text-align: center;
  }

  .upload-copy {
    text-align: center;
  }

  .doc-row {
    grid-template-columns: 1fr;
  }

  .doc-ops {
    justify-content: flex-start;
  }

  .page-hero-row {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* Bouquet isolated frontend additions. The base layout above is copied
   from advertisement/web; these rules only add Bouquet data states. */
.auth-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 48px 24px;
}
.view.auth-view[hidden] {
  display: none !important;
}
.auth-shell {
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid rgba(38, 48, 65, .12);
  border-radius: 24px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 18px 58px rgba(38, 48, 65, .12);
}
.auth-brand { display:flex; align-items:center; gap:16px; margin-bottom:30px; }
.auth-logo { width:54px; height:54px; border-radius:50%; object-fit:cover; }
.auth-kicker { margin:0 0 5px; color:#6c78a4; font-size:12px; letter-spacing:.08em; }
.auth-brand h1 { margin:0; color:#273149; font-size:28px; }
.auth-brand p:last-child { margin:8px 0 0; color:#798197; font-size:13px; line-height:1.6; }
.auth-form { display:grid; gap:16px; }
.auth-form[hidden] { display:none !important; }
.auth-form .field { display:grid; gap:8px; }
.auth-form input { width:100%; box-sizing:border-box; }
.auth-submit { width:100%; min-height:44px; }
.auth-error { min-height:20px; margin:0; color:#cf4d4d; font-size:13px; }
.auth-links{display:flex;justify-content:center;gap:20px}.auth-links button,.agreement-open{border:0;background:none;color:#52649b;cursor:pointer;text-decoration:underline;font:inherit}.verification-row{display:grid;grid-template-columns:1fr auto;align-items:end;gap:10px}.verification-row .btn{height:42px}.check-row{display:flex;align-items:flex-start;gap:9px;color:#5f687c;font-size:13px;line-height:1.55}.check-row input{width:auto!important;margin-top:3px}.turnstile-slot{min-height:65px}.agreement-dialog{width:min(680px,calc(100% - 32px));border:0;border-radius:22px;padding:0;box-shadow:0 26px 90px rgba(25,32,54,.28)}.agreement-dialog::backdrop{background:rgba(25,32,54,.55)}.agreement-head{display:flex;justify-content:space-between;align-items:center;padding:22px 24px;border-bottom:1px solid #e7e9f0}.agreement-head strong,.agreement-head small{display:block}.agreement-head small{margin-top:4px;color:#8c94a7}.agreement-head button{border:0;background:none;font-size:28px;cursor:pointer}.agreement-copy{max-height:55vh;overflow:auto;padding:8px 26px 28px;line-height:1.8;color:#535d72}.agreement-copy h2{font-size:16px;color:#2c3855;margin:22px 0 6px}.agreement-copy p{margin:0}.agreement-end{margin-top:26px!important;padding:14px;background:#f1f3fa;border-radius:10px}.agreement-dialog>.btn{margin:0 24px 24px;width:calc(100% - 48px)}
.conv-empty { color:#9aa1b3; font-size:13px; padding:14px 12px; }
.conv { display:flex; align-items:center; gap:9px; min-width:0; }
.conv-status { flex:0 0 7px; width:7px; height:7px; border-radius:50%; background:#c4cad7; }
.conv-status.is-open { background:#4bbd86; box-shadow:0 0 0 3px rgba(75,189,134,.14); }
.conv__body { min-width:0; flex:1; display:grid; gap:3px; }
.conv__title, .conv__preview { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conv__preview { color:#8e96a8; font-size:12px; }
.conv__time { color:#a5aabd; font-size:11px; white-space:nowrap; opacity:0; transition:opacity .14s ease; }
.conv:hover .conv__time { opacity:1; }
.account-role-badge { display:inline-flex; align-items:center; min-height:30px; padding:0 10px; border-radius:999px; color:#4f5d88; background:#edf0fb; font-size:12px; white-space:nowrap; }
.inline-setting-form { display:flex; align-items:flex-end; flex-wrap:wrap; gap:12px; }
.inline-setting-form .field { flex:1 1 180px; min-width:150px; }
.setting-actions { display:flex; gap:10px; align-items:center; margin-top:14px; }
.admin-create-form { align-items:flex-end; margin-bottom:22px; }
.admin-table-wrap { overflow:auto; border-top:1px solid rgba(38,48,65,.1); }
.admin-table { width:100%; border-collapse:collapse; min-width:650px; font-size:13px; }
.admin-table th, .admin-table td { padding:13px 10px; text-align:left; border-bottom:1px solid rgba(38,48,65,.08); vertical-align:middle; }
.admin-table th { color:#7b8498; font-weight:600; font-size:12px; }
.admin-table td strong, .admin-table td small { display:block; }
.admin-table td small { color:#9aa1b3; margin-top:3px; }
.admin-actions { display:flex; flex-wrap:wrap; gap:7px; align-items:center; }
.status-text { display:inline-flex; margin-left:10px; padding:3px 8px; border-radius:999px; font-size:11px; }
.status-text.active { color:#25855b; background:#e7f7ee; }
.status-text.disabled { color:#a27343; background:#fbf0df; }
.danger { color:#b84d58 !important; }
.automation-form { display:grid; gap:13px; }
.automation-form-grid { display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:12px; align-items:end; }
.automation-form-grid .field { min-width:0; }
.field-checkbox { display:flex !important; flex-direction:row; align-items:center; gap:8px; padding-bottom:9px; }
.field-checkbox input { width:16px; height:16px; }
.automation-list { display:grid; gap:10px; margin-top:20px; }
.automation-item { display:flex; justify-content:space-between; gap:18px; padding:14px 0; border-top:1px solid rgba(38,48,65,.09); }
.automation-item strong { color:#303950; }
.automation-item p { margin:8px 0 0; color:#8b93a5; font-size:12px; line-height:1.55; }
.msg-empty { color:#9ba2b3; }
.message-media-card { display:inline-flex; flex-direction:column; gap:0; max-width:min(100%,520px); margin:8px 0; vertical-align:top; }
.message-image-card { max-width:min(100%,460px); }
.message-image { display:block; max-width:100%; max-height:460px; border:1px solid rgba(39,49,73,.14); border-radius:22px; cursor:zoom-in; object-fit:contain; background:#f7f8fb; }
.douyin-video-cover { display:block; max-width:100%; text-decoration:none; }
.douyin-video-cover .message-image { cursor:pointer; }
.message-audio { display:block; width:min(100%,440px); min-height:40px; }
.message-audio-card { display:flex; width:min(100%,440px); max-width:100%; box-sizing:border-box; }
.message-audio-card .message-audio { width:100%; }
.message-video { display:block; width:min(100%,520px); max-height:460px; border:1px solid rgba(39,49,73,.14); border-radius:12px; background:#10131a; object-fit:contain; }
.message-video-card { display:flex; width:min(100%,520px); max-width:100%; }
.message-media-card--unavailable { min-width:180px; padding:10px 12px; border:1px solid rgba(39,49,73,.12); border-radius:11px; background:#f7f8fb; }
.message-media-unavailable { display:flex; align-items:center; gap:7px; color:#6f7890; font-size:12px; }
.message-media-unavailable svg { width:15px; height:15px; flex:0 0 auto; }
.msg-attachments { display:flex; flex-direction:column; align-items:stretch; width:100%; margin-top:4px; }
.msg-attachments .message-media-card { margin:8px 0 0; }
#viewChat .messages .msg--user .msg-attachments { align-items:flex-start; }
#viewChat .messages .msg--assistant .msg-attachments { align-items:flex-end; }

/* Text and media are separate visual surfaces.  Keep the attachment rail
   transparent even if an older render left it under a text bubble. */
#viewChat .messages .msg-col > .msg-attachments,
#viewChat .messages .msg-body > .msg-attachments {
  display: flex;
  width: 100%;
  padding: 0 !important;
  margin-top: 4px;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#viewChat .messages .msg--user .msg-col > .msg-text-bubble,
#viewChat .messages .msg--assistant .msg-col > .msg-text-bubble {
  position: relative;
  z-index: 1;
}
.request-debug {
  width: min(760px, 100%);
  margin: 9px 0 0 auto;
  border: 1px solid rgba(39, 49, 73, 0.11);
  border-radius: 12px;
  background: rgba(248, 249, 252, 0.9);
  color: var(--muted);
  overflow: hidden;
}
.request-debug > summary,
.filtered-user-content > summary,
.debug-entry--folded > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.request-debug > summary::-webkit-details-marker,
.filtered-user-content > summary::-webkit-details-marker,
.debug-entry--folded > summary::-webkit-details-marker { display: none; }
.request-debug > summary {
  min-height: 31px;
  padding: 0 11px;
  font-size: 12px;
  color: #69738b;
}
.request-debug > summary svg,
.filtered-user-content > summary svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.8;
}
.request-debug > summary::after,
.filtered-user-content > summary::after,
.debug-entry--folded > summary::after {
  content: "⌄";
  margin-left: auto;
  color: #a5adbc;
  transition: transform 0.18s ease;
}
.request-debug[open] > summary::after,
.filtered-user-content[open] > summary::after,
.debug-entry--folded[open] > summary::after { transform: rotate(180deg); }
.request-debug-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a1aabd;
}
.request-debug-body {
  display: grid;
  gap: 7px;
  padding: 0 11px 11px;
}
.debug-entry {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding-top: 7px;
  border-top: 1px solid rgba(39, 49, 73, 0.07);
}
.debug-entry-label {
  color: #7c879b;
  font-size: 12px;
  line-height: 1.5;
}
.debug-entry-value {
  min-width: 0;
  margin: 0;
  color: #4d5870;
  font: 12px/1.55 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.debug-entry--folded {
  padding-top: 7px;
  border-top: 1px solid rgba(39, 49, 73, 0.07);
}
.debug-entry--folded > summary {
  min-height: 22px;
  font-size: 12px;
}
.debug-entry-action,
.filtered-user-action {
  margin-left: auto;
  color: #9aa5b8;
  font-size: 11px;
}
.debug-entry--folded > .debug-entry-value {
  max-height: 260px;
  margin: 7px 0 0 97px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(236, 239, 246, 0.9);
  overflow: auto;
}
.request-debug-note {
  margin: 3px 0 0;
  color: #a4adbd;
  font-size: 11px;
  line-height: 1.5;
}
.filtered-user-content {
  border: 1px solid rgba(39, 49, 73, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.42);
  overflow: hidden;
}
.filtered-user-content > summary {
  min-height: 33px;
  padding: 0 10px;
  color: #6d7890;
  font-size: 12px;
}
.filtered-user-content > pre {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  border-top: 1px solid rgba(39, 49, 73, 0.08);
  color: #59647a;
  font: 12px/1.6 var(--font-mono);
  white-space: pre-wrap;
  overflow: auto;
}
.thinking-panel { margin:0 0 12px; overflow:hidden; border:1px solid rgba(98,117,175,.2); border-radius:11px; background:#f7f8fc; }
.thinking-panel .fold-title { width:100%; display:flex; justify-content:space-between; align-items:center; border:0; padding:9px 12px; color:#65729a; background:transparent; cursor:pointer; text-align:left; font-size:12px; }
.thinking-panel .fold-chevron { transition:transform .18s ease; }
.thinking-panel.is-expanded .fold-chevron { transform:rotate(180deg); }
.thinking-panel .fold-body { display:none; padding:0 13px 12px; }
.thinking-panel.is-expanded .fold-body { display:block; }
.thinking-content { max-height:300px; overflow:auto; color:#7c859c; font-size:12px; }
.thinking-panel.is-live { border-color:#8da5ee; box-shadow:0 0 0 3px rgba(141,165,238,.09); }
.timeline-event-row { display:flex; justify-content:center; width:100%; max-width:none; margin:0 auto 14px; padding-inline:20px; box-sizing:border-box; }
.timeline-event-chip { display:inline-flex; align-items:center; width:fit-content; max-width:min(85%,36rem); padding:10px 16px; border:0; border-radius:22px; color:#777; background:rgba(244,244,244,.5); font-size:12px; line-height:1.5; text-align:center; box-shadow:none; }
.timeline-event-chip-title { display:inline-flex; align-items:center; justify-content:center; gap:10px; }
.timeline-event-chip-time { display:none; }
.event-detail { display:none; }
.composer-shell textarea.is-holding { box-shadow:0 0 0 3px rgba(87,122,223,.22); }
.tool-chip.is-on { color:#4f6ec5; border-color:#91a8ec; background:#eef2ff; }
.disclaimer { max-width:860px; }
.is-auth-view .app { grid-template-columns: 1fr; }
.is-auth-view .sidebar, .is-auth-view .sidebar-fab, .is-auth-view .menu-fab { display:none; }
.is-auth-view .main { width:100%; }

.composer-media-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 14;
  display: grid;
  gap: 2px;
  min-width: 146px;
  padding: 6px;
  border: 1px solid rgba(38,48,65,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 16px 36px rgba(38,48,65,.16);
}
.composer-media-menu[hidden] { display: none; }
.composer-media-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  color: #59647d;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.composer-media-option svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer-media-option:hover,
.composer-media-option:focus-visible {
  color: #174caa;
  background: #f2f5ff;
}
.composer-media-option:focus-visible {
  outline: 2px solid rgba(23,105,245,.28);
  outline-offset: -2px;
}
.composer-media-option:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.quick-replies-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 12;
  padding: 12px;
  border: 1px solid rgba(38,48,65,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 45px rgba(38,48,65,.16);
}
.quick-replies-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:0 0 8px;
  color:#303950;
  font-size:13px;
}
.quick-replies-head .icon-round {
  width:28px;
  height:28px;
}
.quick-replies-head .icon-round svg {
  width:14px;
  height:14px;
}
.quick-replies-list {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
  max-height:230px;
  overflow:auto;
}
.quick-reply-option {
  display:grid;
  gap:4px;
  min-width:0;
  padding:10px 11px;
  border:1px solid rgba(38,48,65,.1);
  border-radius:10px;
  color:#59647d;
  background:#fafbfe;
  text-align:left;
  cursor:pointer;
}
.quick-reply-option:hover {
  border-color:#9aafea;
  background:#f2f5ff;
}
.quick-reply-option strong,
.quick-reply-option span {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.quick-reply-option strong { color:#303950; font-size:12px; }
.quick-reply-option span { color:#8a93a7; font-size:11px; }
.quick-replies-empty { margin:8px 2px; color:#939bad; font-size:12px; }

/* app-shell-v1: authenticated client navigation and dashboard surfaces. The
   conversation sidebar remains a separate inner workspace column. */
:root {
  --global-nav-w: 72px;
  --home-surface: #f7f7f8;
  --home-line: rgba(20, 25, 35, 0.08);
  --home-muted: #7d8490;
}

.app {
  grid-template-columns: var(--global-nav-w) minmax(0, 1fr) !important;
  height: 100dvh;
  min-height: 0;
  box-sizing: border-box;
}

.app.is-chat-section {
  grid-template-columns: var(--global-nav-w) var(--side-w) minmax(0, 1fr) !important;
}

.app.is-chat-section.is-collapsed {
  grid-template-columns: var(--global-nav-w) 0 minmax(0, 1fr) !important;
}

.app:not(.is-chat-section).is-collapsed {
  grid-template-columns: var(--global-nav-w) minmax(0, 1fr) !important;
}

.global-nav {
  grid-column: 1;
  grid-row: 1;
  z-index: 50;
  display: flex;
  width: var(--global-nav-w);
  min-width: var(--global-nav-w);
  height: 100%;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 18px;
  border-right: 1px solid var(--home-line);
  background: #fff;
}

.global-nav[hidden] { display: none !important; }

.global-nav__logo {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin: 0 0 28px;
  border-radius: 50%;
  overflow: hidden;
  text-decoration: none;
  transition: transform .2s var(--ease), box-shadow .2s ease;
}

.global-nav__logo:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20, 25, 35, .12); }
.global-nav__logo:focus-visible { outline: 3px solid rgba(20, 25, 35, .18); outline-offset: 3px; }
.global-nav__logo img { display: block; width: 100%; height: 100%; object-fit: cover; }

.global-nav__items {
  display: grid;
  width: 100%;
  gap: 8px;
}

.global-nav__item {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 60px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 3px 7px;
  border-radius: 15px;
  color: #7b818b;
  flex-direction: column;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: color .18s ease, background .18s ease, transform .18s var(--ease);
}

.global-nav__item svg { width: 21px; height: 21px; stroke-width: 1.75; }
.global-nav__item:hover { color: #17191d; background: rgba(20, 25, 35, .045); transform: translateY(-1px); }
.global-nav__item.is-active { color: #16181c; background: #f0f1f3; }
.global-nav__item.is-active svg { stroke-width: 2; }
.global-nav__item:focus-visible { outline: 3px solid rgba(20, 25, 35, .18); outline-offset: 2px; }

.global-nav__badge {
  position: absolute;
  top: 5px;
  right: 8px;
  display: grid;
  min-width: 15px;
  height: 15px;
  box-sizing: border-box;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  color: #fff;
  background: #25282e;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.app > .main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.app.is-chat-section > .main { grid-column: 3; }
.app.is-chat-section > #sidebar { grid-column: 2; grid-row: 1; }
.app:not(.is-chat-section) > #sidebar { display: none !important; }
.app.is-auth-view { grid-template-columns: minmax(0, 1fr) !important; }
.app.is-auth-view > .main { grid-column: 1 !important; }
.app.is-auth-view > .global-nav { display: none !important; }
.app:not(.is-chat-section) .sidebar-fab { display: none !important; }
.app.is-chat-section #sidebarFoot { display: none !important; }

.app-home-view,
.app-notifications-view,
.app-account-view { background: #fff; }

.home-scroll,
.notifications-scroll,
.account-scroll {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 25, 35, .16) transparent;
}

.home-shell,
.notifications-shell,
.account-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 72px;
  box-sizing: border-box;
}

.home-brand-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  min-height: 196px;
  padding: 28px 32px;
  border: 1px solid var(--home-line);
  border-radius: 28px;
  background: var(--home-surface);
  box-shadow: 0 18px 50px rgba(20, 25, 35, .045);
}

.home-brand-mark { display: grid; width: 88px; height: 88px; place-items: center; border-radius: 50%; overflow: hidden; background: #fff; box-shadow: 0 8px 24px rgba(20, 25, 35, .1); }
.home-brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.home-brand-wordmark { color: #111318; font-size: clamp(31px, 4vw, 48px); font-weight: 400; letter-spacing: -.045em; line-height: .98; }
.home-brand-subtitle { margin-top: 9px; color: #7c838d; font-size: 14px; letter-spacing: .08em; }
.home-welcome { margin: 22px 0 5px; color: #24272c; font-size: 18px; line-height: 1.35; }
.home-identity-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: #8a909a; font-size: 13px; }
.home-identity-line strong { color: #30343b; font-weight: 600; }
.home-identity-divider { color: #babec5; }
.home-brand-actions { display: grid; justify-items: end; gap: 10px; }
.home-identity-avatar { width: 48px; height: 48px; overflow: hidden; border-radius: 50%; background: #e6e7ea; }
.home-identity-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.home-connection-state { display: inline-flex; align-items: center; gap: 6px; color: #7c838d; font-size: 12px; }
.home-connection-state[data-state="connected"] { color: #3d7658; }
.home-connection-state[data-state="lost"] { color: #a35d5d; }
.home-status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #aeb4bd; }
.home-connection-state[data-state="connected"] .home-status-dot { background: #4b9b70; }
.home-connection-state[data-state="lost"] .home-status-dot { background: #c96b6b; }
.home-primary-actions { display: flex; gap: 8px; }

.home-section { min-width: 0; margin-top: 28px; padding: 24px; border: 1px solid var(--home-line); border-radius: 24px; background: #fff; box-shadow: 0 14px 40px rgba(20, 25, 35, .035); }
.home-section-heading { display: flex; min-width: 0; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.home-section-heading > div { min-width: 0; }
.home-eyebrow { margin: 0 0 5px; color: #9a9fa7; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.home-section h1, .home-section h2 { margin: 0; color: #202329; font-weight: 600; letter-spacing: -.025em; }
.home-section h1 { font-size: 28px; }
.home-section h2 { font-size: 20px; }
.home-live-label { display: inline-flex; align-items: center; gap: 6px; color: #8d939c; font-size: 12px; white-space: nowrap; }
.home-live-label .home-status-dot { background: #4b9b70; }
.home-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.home-metric-card { display: grid; min-width: 0; min-height: 142px; gap: 8px; padding: 20px; border-radius: 18px; background: #f5f5f6; }
.home-metric-label { color: #727984; font-size: 13px; }
.home-metric-value { color: #181a1e; font-size: 38px; font-weight: 400; letter-spacing: -.05em; line-height: 1; }
.home-metric-help { align-self: end; color: #9aa0a9; font-size: 11px; line-height: 1.45; }

.home-content-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr); align-items: start; gap: 20px; }
.home-content-grid > .home-section { min-height: 100%; }
.home-content-grid--lower { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.home-content-grid--lower .home-section { min-height: 270px; }
.text-button, .btn-link { color: #646b75; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.text-button:hover, .btn-link:hover { color: #17191d; }
.home-work-list, .home-notification-list, .home-activity-list, .home-recent-list { display: grid; gap: 8px; }
.home-empty-state, .notification-empty { padding: 30px 12px; color: #a0a6ae; font-size: 13px; text-align: center; }
.home-work-item, .home-notification-item, .home-activity-item, .home-recent-item { min-width: 0; border-radius: 15px; background: #f7f7f8; }
.home-work-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 14px; }
.home-item-avatar { width: 34px; height: 34px; flex: 0 0 34px; overflow: hidden; border-radius: 50%; background: #e0e2e5; }
.home-item-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.home-item-copy { min-width: 0; }
.home-item-copy strong, .home-item-copy span, .home-item-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-item-copy strong { color: #30343b; font-size: 13px; font-weight: 600; }
.home-item-copy span { margin-top: 3px; color: #777e88; font-size: 12px; }
.home-item-copy small { margin-top: 4px; color: #a0a6ae; font-size: 11px; }
.home-item-action { padding: 7px 9px; border-radius: 9px; color: #6d747e; background: #fff; font-size: 11px; white-space: nowrap; }
.home-item-action:hover { color: #1c1f24; background: #ececee; }
.home-item-state { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; color: #8c939d; font-size: 11px; }
.home-item-state .home-status-dot { width: 5px; height: 5px; flex-basis: 5px; }

.home-notification-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px 13px; cursor: pointer; transition: background .18s ease; }
.home-notification-item:hover { background: #f0f1f2; }
.home-notification-item.is-unread { background: #f2f3f5; }
.home-notification-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; color: #676e78; background: #e6e7e9; }
.home-notification-icon svg { width: 15px; height: 15px; }
.home-notification-copy { min-width: 0; }
.home-notification-copy strong, .home-notification-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-notification-copy strong { color: #383c43; font-size: 12px; }
.home-notification-copy span { margin-top: 4px; color: #8b919b; font-size: 11px; }
.home-notification-meta { display: grid; justify-items: end; gap: 5px; color: #a1a6ae; font-size: 10px; white-space: nowrap; }
.home-unread-dot { width: 6px; height: 6px; border-radius: 50%; background: #34383e; }
.home-section-footer { display: flex; align-items: center; justify-content: flex-end; gap: 15px; margin-top: 16px; }

.home-activity-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 13px; }
.home-activity-icon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 9px; color: #747b85; background: #e8e9eb; }
.home-activity-icon svg { width: 14px; height: 14px; }
.home-activity-copy { min-width: 0; }
.home-activity-copy strong { display: block; overflow: hidden; color: #474c54; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.home-activity-copy span { display: block; margin-top: 3px; overflow: hidden; color: #9399a2; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.home-activity-time { color: #a6abb2; font-size: 10px; white-space: nowrap; }

.home-recent-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 11px 13px; }
.home-recent-copy { min-width: 0; }
.home-recent-copy strong, .home-recent-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-recent-copy strong { color: #454a52; font-size: 12px; }
.home-recent-copy span { margin-top: 4px; color: #9399a2; font-size: 11px; }
.home-recent-time { color: #a6abb2; font-size: 10px; white-space: nowrap; }

.home-personal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.home-personal-stat { display: grid; gap: 9px; min-width: 0; padding: 16px; border-radius: 15px; background: #f6f6f7; }
.home-personal-stat span { overflow: hidden; color: #858b95; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.home-personal-stat strong { color: #23262b; font-size: 23px; font-weight: 400; letter-spacing: -.04em; }
.home-trend { display: flex; align-items: end; gap: 7px; min-height: 58px; margin-top: 18px; padding: 10px 4px 0; }
.home-trend-bar { min-width: 10px; flex: 1 1 0; max-width: 34px; border-radius: 5px 5px 2px 2px; background: #555b65; }
.home-trend-empty { color: #a0a6ae; font-size: 12px; }

.module-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 8px 0 28px; }
.module-header h1 { margin: 0; color: #1c1f24; font-size: 32px; font-weight: 500; letter-spacing: -.04em; }
.module-description { max-width: 520px; margin: 10px 0 0; color: #8b919a; font-size: 13px; line-height: 1.6; }
.notification-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.notification-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.notification-filter { min-height: 34px; padding: 0 12px; border-radius: 999px; color: #7f858e; background: #f3f3f4; font-size: 12px; }
.notification-filter:hover, .notification-filter.is-active { color: #202329; background: #e7e8ea; }
.notification-unread-toggle { display: inline-flex; align-items: center; gap: 7px; color: #7f858e; font-size: 12px; white-space: nowrap; }
.notification-unread-toggle input { width: 15px; height: 15px; accent-color: #24272d; }
.notification-center-list { display: grid; gap: 8px; }
.notification-center-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 17px 18px; border: 1px solid var(--home-line); border-radius: 17px; background: #fff; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.notification-center-item:hover { border-color: rgba(20, 25, 35, .16); background: #fafafa; }
.notification-center-item.is-unread { border-color: rgba(20, 25, 35, .15); background: #f7f7f8; }
.notification-center-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: #5d646d; background: #e9eaec; }
.notification-center-icon svg { width: 17px; height: 17px; }
.notification-center-copy { min-width: 0; }
.notification-center-copy strong { display: block; color: #30343a; font-size: 14px; font-weight: 600; }
.notification-center-copy p { margin: 6px 0 0; color: #717883; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.notification-center-copy small { display: block; margin-top: 8px; color: #a0a6ae; font-size: 11px; }
.notification-center-meta { display: grid; justify-items: end; gap: 8px; color: #9ba1aa; font-size: 11px; white-space: nowrap; }
.notification-center-meta .home-unread-dot { width: 7px; height: 7px; }
.notification-load-more { display: block; width: 100%; margin-top: 18px; }

.account-profile-panel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 26px; border: 1px solid var(--home-line); border-radius: 24px; background: var(--home-surface); }
.account-profile-avatar { width: 80px; height: 80px; overflow: hidden; border-radius: 50%; background: #e1e3e6; }
.account-profile-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.account-profile-copy { min-width: 0; }
.account-profile-copy h2 { margin: 0; color: #22252a; font-size: 25px; font-weight: 500; }
.account-profile-copy p { margin: 7px 0 0; color: #858b94; font-size: 13px; }
.account-profile-copy span { display: inline-flex; margin-top: 10px; color: #727984; font-size: 11px; }
.account-edit-button { align-self: start; }
.account-stats-section, .account-preferences-section { margin-top: 20px; }
.account-stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.account-settings-link { display: flex; width: 100%; min-height: 54px; align-items: center; justify-content: space-between; padding: 0 4px; color: #5e6670; font-size: 13px; text-align: left; }
.account-settings-link > span { display: inline-flex; align-items: center; gap: 9px; }
.account-settings-link svg { width: 17px; height: 17px; }
.account-settings-link:hover { color: #17191d; }

.app-profile-dialog-layer { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 24px; box-sizing: border-box; }
.app-profile-dialog-layer[hidden] { display: none !important; }
.app-profile-dialog-backdrop { position: absolute; inset: 0; background: rgba(33, 38, 46, .43); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.app-profile-dialog { position: relative; z-index: 1; width: min(520px, 100%); padding: 28px; border: 1px solid rgba(20, 25, 35, .1); border-radius: 24px; background: #fff; box-shadow: 0 28px 90px rgba(20, 25, 35, .25); }
.app-profile-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 27px; }
.app-profile-dialog-header h2 { margin: 0; color: #202329; font-size: 22px; font-weight: 500; }
.app-dialog-close { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 0; color: #737a84; background: transparent; }
.app-dialog-close:hover { color: #17191d; background: #f3f3f4; }
.app-dialog-close svg { width: 19px; height: 19px; }
.app-profile-form { display: grid; gap: 18px; }
.app-profile-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 18px; }
.app-profile-avatar-row { min-height: 72px; }
.app-profile-avatar-preview { width: 72px; height: 72px; flex: 0 0 72px; overflow: hidden; border-radius: 50%; background: #e4e5e7; }
.app-profile-avatar-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.app-profile-upload { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; padding: 0 13px; border: 0; border-radius: 10px; color: #646b75; background: #f1f2f4; box-shadow: 0 5px 14px rgba(20, 25, 35, .08); cursor: pointer; font-size: 13px; transition: color .18s ease, background .18s ease, box-shadow .18s ease; }
.app-profile-upload:hover { color: #17191d; background: #e7e9ec; box-shadow: 0 7px 18px rgba(20, 25, 35, .12); }
.app-profile-upload svg { width: 17px; height: 17px; }
.app-profile-name-row { padding-top: 18px; border-top: 1px solid var(--home-line); }
.app-profile-name-row > span { color: #5f6670; font-size: 13px; white-space: nowrap; }
.app-profile-name-row input { width: min(320px, 72%); min-height: 42px; padding: 0 13px; box-sizing: border-box; border: 1px solid rgba(20, 25, 35, .14); border-radius: 10px; outline: none; background: #fff; }
.app-profile-name-row input:focus { border-color: rgba(20, 25, 35, .36); box-shadow: 0 0 0 3px rgba(20, 25, 35, .06); }
.app-profile-error { min-height: 20px; margin: 14px 0 0; color: #b84d58; font-size: 12px; }
.app-profile-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

@media (max-width: 1000px) {
  .home-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-personal-grid, .account-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app, .app.is-chat-section, .app.is-chat-section.is-collapsed, .app:not(.is-chat-section).is-collapsed { grid-template-columns: minmax(0, 1fr) !important; }
  .app > .main, .app.is-chat-section > .main { grid-column: 1 !important; grid-row: 1; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .global-nav { position: fixed; inset: auto 0 0; display: block; width: 100%; min-width: 0; height: calc(68px + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom); border-top: 1px solid var(--home-line); border-right: 0; }
  .global-nav__logo { display: none; }
  .global-nav__items { display: grid; width: 100%; height: 68px; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; gap: 2px; }
  .global-nav__item { min-height: 60px; border-radius: 12px; }
  .global-nav__badge { top: 6px; right: calc(50% - 22px); }
  .app:not(.is-chat-section) > #sidebar { display: none !important; }
  .app.is-chat-section > #sidebar { grid-column: 1; }
  .app.is-chat-section .sidebar-fab.menu-fab { display: grid !important; }
  .home-shell, .notifications-shell, .account-shell { width: min(100% - 28px, 700px); padding-top: 22px; padding-bottom: 40px; }
  .home-brand-panel { grid-template-columns: auto minmax(0, 1fr); gap: 16px; padding: 24px; }
  .home-brand-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; justify-items: stretch; padding-top: 8px; border-top: 1px solid var(--home-line); }
  .home-primary-actions { margin-left: auto; }
  .home-content-grid, .home-content-grid--lower { grid-template-columns: 1fr; gap: 0; }
  .home-content-grid > .home-section { min-height: 0; }
  .home-personal-grid, .account-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .home-shell, .notifications-shell, .account-shell { width: min(100% - 20px, 700px); }
  .home-brand-panel { display: flex; align-items: flex-start; flex-wrap: wrap; padding: 20px; border-radius: 22px; }
  .home-brand-mark { width: 62px; height: 62px; }
  .home-brand-wordmark { font-size: 34px; }
  .home-welcome { margin-top: 15px; font-size: 16px; }
  .home-brand-actions { width: 100%; flex-wrap: wrap; gap: 9px; }
  .home-primary-actions { width: 100%; margin-left: 0; }
  .home-primary-actions .btn { flex: 1 1 0; }
  .home-section { padding: 18px 15px; border-radius: 19px; }
  .home-metric-card { min-height: 120px; padding: 15px; }
  .home-metric-value { font-size: 32px; }
  .module-header { gap: 12px; padding-bottom: 20px; }
  .module-header h1 { font-size: 28px; }
  .module-header > .btn { flex: 0 0 auto; }
  .notification-toolbar { align-items: flex-start; flex-direction: column; }
  .notification-unread-toggle { align-self: flex-end; }
  .notification-center-item { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 14px; }
  .notification-center-meta { grid-column: 2; display: flex; align-items: center; justify-content: space-between; }
  .account-profile-panel { grid-template-columns: auto minmax(0, 1fr); padding: 19px; }
  .account-edit-button { grid-column: 1 / -1; width: 100%; }
  .app-profile-dialog-layer { padding: 12px; }
  .app-profile-dialog { padding: 20px 17px; border-radius: 20px; }
  .app-profile-name-row input { width: 70%; }
}
.assistant-form, .quick-reply-form { display:grid; gap:13px; }
.assistant-form-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
  align-items:end;
}

/* app-shell-visual-v2: keep the dashboard on the same quiet, type-led
   surface as the conversation page and the public bouquet.chat site. */
:root {
  --font-site: "Bouquet App", "Noto Serif TC", "Songti TC", serif;
  --font-ui: var(--font-site);
  --font: var(--font-site);
  --home-line: transparent;
}

.app,
.app button,
.app input,
.app textarea,
.app select,
.app .global-nav,
.app .main {
  font-family: var(--font-site) !important;
}

.global-nav {
  border-right: 0;
  background: var(--bg-side);
}

.global-nav__item:hover { background: var(--bg-side-hover); }
.global-nav__item.is-active { background: var(--bg-side-active); }

.home-brand-panel,
.home-section,
.account-profile-panel,
.notification-center-item,
.app-profile-dialog {
  border: 0 !important;
  box-shadow: none !important;
}

.home-brand-panel {
  background: var(--bg-side);
}

.home-section {
  background: transparent;
}

.home-metric-card,
.home-work-item,
.home-notification-item,
.home-activity-item,
.home-recent-item,
.home-personal-stat {
  border: 0 !important;
  box-shadow: none !important;
}

.home-metric-card { background: var(--user-bg); }
.home-metric-meta { align-self: end; color: #8e8e8e; font-size: 11px; line-height: 1.45; }
.home-metric-help { display: none !important; }

.home-work-item,
.home-activity-item,
.home-recent-item { background: var(--user-bg); }

.home-notification-item,
.home-notification-item.is-unread { background: var(--user-bg); }
.home-notification-item:hover { background: var(--bg-side-active); }

.home-personal-stat { background: var(--user-bg); }

.notification-center-item,
.notification-center-item.is-unread { background: var(--user-bg); }
.notification-center-item:hover { border-color: transparent !important; background: var(--bg-side-active); }

.account-profile-panel { background: var(--bg-side); }
.app-profile-dialog { background: var(--bg); }

.home-section-heading { margin-bottom: 16px; }
.home-section h1,
.home-section h2,
.module-header h1 { font-family: var(--font-site) !important; }

.module-description,
.home-eyebrow,
.home-live-label { display: none !important; }

.home-trend-empty { color: #8e8e8e; }

@media (max-width: 900px) {
  .global-nav {
    border-top: 0;
    background: rgba(247, 247, 248, .96);
  }

  .home-brand-actions { border-top: 0; }
}
.assistant-form-grid .field { min-width:0; }
.assistant-form input, .assistant-form textarea,
.quick-reply-form input, .quick-reply-form textarea { width:100%; box-sizing:border-box; }
.assistant-form .field-checkbox { min-height:38px; }
.assistant-form .field-help { font-size:12px; }
.quick-replies-settings-list { display:grid; gap:10px; margin-top:20px; }
.quick-reply-setting-item {
  display:flex;
  justify-content:space-between;
  gap:18px;
  padding:14px 0;
  border-top:1px solid rgba(38,48,65,.09);
}
.quick-reply-setting-item strong { color:#303950; }
.quick-reply-setting-item p {
  margin:7px 0 0;
  color:#8b93a5;
  font-size:12px;
  line-height:1.55;
  white-space:pre-wrap;
}
.quick-reply-setting-item .btn { display:inline-flex; align-items:center; gap:5px; }
.quick-reply-setting-item .btn svg { width:13px; height:13px; }
.tool-chip.is-loading { pointer-events:none; }
.tool-chip.is-loading svg { animation: bouquet-spin .9s linear infinite; }
@keyframes bouquet-spin { to { transform:rotate(360deg); } }

@media (max-width: 800px) {
  .auth-view { padding:24px 15px; }
  .auth-shell { padding:25px 20px; }
  .automation-form-grid { grid-template-columns:repeat(2, minmax(0,1fr)); }
  .assistant-form-grid { grid-template-columns:repeat(2, minmax(0,1fr)); }
  .quick-replies-list { grid-template-columns:1fr; }
  .automation-item { flex-direction:column; gap:12px; }
  .quick-reply-setting-item { flex-direction:column; gap:12px; }
  .debug-entry { grid-template-columns:1fr; gap:3px; }
  .debug-entry--folded > .debug-entry-value { margin-left:0; }
}

/* Performance: keep the loaded paginated list continuous while letting the
   browser skip painting rows that are far outside the viewport. */
.conv-list {
  display: block;
  min-height: 100%;
}
.conv-virtual-spacer {
  display: none !important;
}
.conv {
  height: 76px;
  min-height: 76px;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: 76px;
}

/* Three-line conversation item: title, preview, timestamp. */
.conv__body { padding-right: 0; }
.conv__time {
  position: static;
  display: block;
  opacity: 1;
  color: #a5aabd;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

/* Chat / settings share one compact content rail in the isolated frontend. */
.messages,
.settings-layout {
  width: min(var(--content-w), 100%);
  margin-inline: auto;
}

.messages {
  padding: 8px var(--content-gutter) 24px;
}

.settings-layout {
  padding: 16px var(--content-gutter) 48px;
}

.settings-stack {
  margin-top: 6px;
}

.settings-hero {
  padding-bottom: 8px;
  margin-bottom: 0;
}

/* ============================================================
   Bouquet global visual polish · 2026-08-21
   One alignment system for auth, workspace, settings and admin states.
   ============================================================ */
:root {
  --brand: #1769f5;
  --brand-strong: #0d56d8;
  --brand-soft: #eef5ff;
  --brand-ring: rgba(23, 105, 245, 0.18);
  --control-h: 42px;
}

::selection {
  color: #fff;
  background: rgba(23, 105, 245, 0.8);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}

.side-link:hover,
.conv:hover {
  background: rgba(23, 105, 245, 0.055);
}

.conv.is-active {
  color: #174caa;
  background: rgba(23, 105, 245, 0.09);
}

.conv.is-active .conv__preview,
.conv.is-active .conv__time {
  color: #7185aa;
}

.icon-round:hover {
  color: var(--brand);
  border-color: rgba(23, 105, 245, 0.24);
}

.auth-view {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  min-height: 100%;
  padding: 32px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% -18%, rgba(23, 105, 245, 0.075), transparent 34%),
    #fff;
}

.auth-shell {
  width: min(100%, 460px);
  margin: auto 0;
  padding: 36px;
  border-color: rgba(16, 24, 40, 0.11);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 70px rgba(28, 55, 96, 0.11);
}

.auth-shell:has(#registerForm:not([hidden])) {
  width: min(100%, 500px);
}

.auth-brand {
  align-items: center;
  margin-bottom: 28px;
}

.auth-logo {
  width: 52px;
  height: 52px;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.08);
}

.auth-kicker {
  color: #5677b8;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.auth-brand h1 {
  color: #17233a;
  font-size: 26px;
  line-height: 1.22;
  letter-spacing: -0.025em;
}

.auth-brand p:last-child {
  max-width: 31em;
  color: #737f96;
  line-height: 1.55;
}

.auth-form {
  gap: 14px;
}

.auth-form .field {
  gap: 7px;
}

.auth-form .field-label {
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.auth-form input,
.auth-form select {
  min-height: 44px;
  border-color: rgba(16, 24, 40, 0.13);
  border-radius: 11px;
  background-color: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.auth-form input:hover,
.auth-form select:hover {
  border-color: rgba(23, 105, 245, 0.34);
}

.auth-form input:focus,
.auth-form select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.auth-submit,
.btn.primary,
.send {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 8px 20px rgba(23, 105, 245, 0.18);
}

.auth-submit:hover,
.btn.primary:hover,
.send:hover:not(:disabled) {
  color: #fff;
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  box-shadow: 0 11px 24px rgba(23, 105, 245, 0.24);
}

.auth-submit {
  min-height: 46px;
  margin-top: 2px;
  border-radius: 11px;
}

.auth-error:empty {
  min-height: 0;
}

.auth-links {
  min-height: 28px;
  align-items: center;
  gap: 22px;
}

.auth-links button,
.agreement-open {
  color: #3f5f9e;
  font-size: 13px;
  font-weight: 500;
  text-underline-offset: 3px;
  text-decoration-color: rgba(63, 95, 158, 0.35);
}

.auth-links button:hover,
.agreement-open:hover {
  color: var(--brand);
  text-decoration-color: currentColor;
}

.verification-row {
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
}

.verification-row .btn {
  width: 118px;
  height: 44px;
  border-radius: 11px;
  white-space: nowrap;
}

.turnstile-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.turnstile-slot[hidden] {
  display: none !important;
  min-height: 0 !important;
}

.turnstile-slot:empty {
  min-height: 0;
}

.turnstile-slot.is-active {
  min-height: 65px;
}

.verification-row > .turnstile-slot {
  grid-column: 1 / -1;
  width: 100%;
}

.auth-error {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agreement-open {
  justify-self: center;
  min-height: 28px;
}

.check-row {
  gap: 10px;
  color: #58657b;
  font-size: 13px;
}

.check-row input {
  width: 16px !important;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--brand);
}

.agreement-dialog {
  width: min(720px, calc(100% - 32px));
  max-height: min(86dvh, 820px);
  overflow: hidden;
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(16, 24, 40, 0.24);
}

.agreement-dialog::backdrop {
  background: rgba(16, 24, 40, 0.52);
  backdrop-filter: blur(4px);
}

.agreement-head {
  min-height: 76px;
  padding: 18px 22px;
}

.agreement-head strong {
  color: #17233a;
  font-size: 17px;
}

.agreement-head button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #667085;
  border-radius: 50%;
}

.agreement-head button:hover {
  color: var(--ink);
  background: #f2f4f7;
}

.agreement-head button svg {
  width: 19px;
  height: 19px;
}

.agreement-copy {
  max-height: min(58dvh, 560px);
  padding: 10px 28px 30px;
  scroll-padding: 20px;
}

.agreement-head h1 {
  margin: 0;
  color: #243453;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
}

.agreement-copy h2 {
  color: #243453;
  font-size: 17px;
}

.agreement-copy h3 {
  margin: 16px 0 4px;
  color: #52627f;
  font-size: 14px;
  font-weight: 700;
}

.agreement-dialog > .btn {
  height: 44px;
  border-radius: 11px;
}

.chat-bar {
  /* chat-header-fade-v1: transition into the message stream without a rule. */
  position: relative;
  border-bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.94) 0%,
    rgba(255, 255, 255, 0.78) 68%,
    rgba(255, 255, 255, 0) 100%
  );
  backdrop-filter: blur(12px);
}

.top-title {
  letter-spacing: -0.015em;
}

.messages,
.composer {
  width: min(48rem, 100%);
}

.messages {
  padding-inline: 20px;
}

.request-debug,
.thinking-panel {
  border-color: rgba(16, 24, 40, 0.1);
  background: #f8fafc;
}

.composer-shell {
  border-color: rgba(16, 24, 40, 0.12);
  border-radius: 24px;
  box-shadow: 0 12px 34px rgba(16, 24, 40, 0.08);
}

.composer-shell:focus-within {
  border-color: rgba(23, 105, 245, 0.5);
  box-shadow: 0 0 0 4px var(--brand-ring), 0 15px 38px rgba(16, 24, 40, 0.09);
}

.tool-chip:hover,
.tool-chip.is-on {
  color: #174caa;
  border-color: rgba(23, 105, 245, 0.14);
  background: var(--brand-soft);
}

.settings-layout {
  width: min(840px, 100%);
  padding: 28px 36px 80px;
}

.settings-hero {
  padding-bottom: 16px;
}

.settings-hero h1 {
  color: #17233a;
  font-size: 26px;
  letter-spacing: -0.025em;
}

.settings-hero p {
  margin-top: 4px;
  color: #7a8598;
}

.client-section {
  padding: 30px 0;
}

.section-title {
  color: #27364f;
  font-size: 14px;
  font-weight: 700;
}

.field.field-row {
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 18px;
  min-height: 46px;
}

.field.field-row input,
.field.field-row select,
.field.field-row .split input,
.field input,
.field textarea,
.field select {
  border-color: rgba(16, 24, 40, 0.12);
}

.field.field-row input:focus,
.field.field-row select:focus,
.field.field-row .split input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.account-role-badge {
  min-height: 40px;
  color: #3f5f9e;
  background: #edf3ff;
}

.app-key-setting {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.app-key-control,
.app-key-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.app-key-control input {
  flex: 1 1 260px;
  min-width: 0;
}

.app-key-status {
  margin-left: 2px;
}

.assistant-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.assistant-form-grid .field-checkbox {
  grid-column: 1 / -1;
  width: max-content;
  justify-self: start;
  justify-content: flex-start;
  min-height: 34px;
  padding: 0;
}

.assistant-form-grid .field-checkbox span {
  white-space: nowrap;
}

.assistant-form > .field-checkbox {
  width: max-content;
  min-height: 34px;
  margin: 0;
  padding: 0;
  justify-content: flex-start;
}

.assistant-form > .field-checkbox span {
  white-space: nowrap;
}

#assistantSystemPrompt,
#automationReply {
  min-height: 128px;
}

#quickReplyText {
  min-height: 112px;
}

.assistant-form-grid label:has(#assistantBaseUrl),
.assistant-form-grid label:has(#assistantModel),
.assistant-form-grid label:has(#assistantApiKey) {
  grid-column: span 2;
}

.assistant-form-grid label:has(#assistantTemperature),
.assistant-form-grid label:has(#assistantMaxTokens) {
  grid-column: span 1;
}

.setting-actions {
  flex-wrap: wrap;
  min-height: 42px;
}

.admin-table-wrap {
  border: 1px solid rgba(16, 24, 40, 0.09);
  border-radius: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 105, 245, 0.3) transparent;
}

.admin-table th {
  background: #f8fafc;
}

.admin-table th:first-child,
.admin-table td:first-child {
  padding-left: 14px;
}

.admin-table th:last-child,
.admin-table td:last-child {
  padding-right: 14px;
}

.automation-item,
.quick-reply-setting-item {
  align-items: flex-start;
}

.ui-modal-card {
  border-color: rgba(16, 24, 40, 0.1);
  box-shadow: 0 26px 80px rgba(16, 24, 40, 0.22);
}

.agreement-copy {
  font-family: "Bouquet Terms", "Bouquet App", "Noto Serif CJK TC", "PingFang TC", serif;
}

.toast {
  background: #17233a;
}

@media (max-width: 900px) {
  .settings-layout {
    width: 100%;
    padding: 26px 24px 72px;
  }

  .field.field-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }
}

@media (max-width: 680px) {
  .auth-view {
    padding: 16px 14px;
  }

  .auth-shell,
  .auth-shell:has(#registerForm:not([hidden])) {
    width: 100%;
    margin: auto 0;
    padding: 24px 20px;
    border-radius: 18px;
    box-shadow: 0 18px 54px rgba(28, 55, 96, 0.1);
  }

  .auth-brand {
    gap: 13px;
    margin-bottom: 22px;
  }

  .auth-logo {
    width: 46px;
    height: 46px;
  }

  .auth-brand h1 {
    font-size: 23px;
  }

  .auth-brand p:last-child {
    margin-top: 5px;
    font-size: 12px;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

  .verification-row .btn {
    width: 112px;
    padding-inline: 9px;
    font-size: 12px;
  }

  .agreement-dialog {
    width: calc(100% - 20px);
    max-height: 92dvh;
    border-radius: 16px;
  }

  .agreement-head {
    min-height: 68px;
    padding: 14px 16px;
  }

  .agreement-copy {
    max-height: 68dvh;
    padding: 6px 18px 24px;
    font-size: 14px;
  }

  .agreement-dialog > .btn {
    margin: 0 16px 16px;
    width: calc(100% - 32px);
  }

  .chat-bar {
    height: 56px;
    min-height: 56px;
    padding: 0 64px;
  }

  .sidebar-fab {
    top: 7px;
  }

  .sidebar-fab.menu-fab {
    top: 7px;
    left: 12px;
    width: 42px;
    height: 42px;
  }

  .top-title {
    max-width: 100%;
    font-size: 16px;
  }

  .messages {
    padding: 12px 16px 22px;
  }

  .dock {
    padding: 0 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer-shell {
    padding: 11px 12px 9px;
    border-radius: 20px;
  }

  .composer-shell textarea {
    font-size: 16px;
  }

  .composer-meta {
    align-items: flex-end;
  }

  .composer-tools {
    gap: 3px 2px;
  }

  .tool-chip {
    height: 29px;
    padding: 0 7px;
    font-size: 11px;
  }

  .send {
    width: 36px;
    height: 36px;
  }

  .disclaimer {
    margin-top: 8px;
    padding-inline: 8px;
    line-height: 1.45;
  }

  .settings-layout {
    padding: 22px 18px 64px;
  }

  .settings-hero h1 {
    font-size: 24px;
  }

  .client-section {
    padding: 26px 0;
  }

  .assistant-form-grid,
  .automation-form-grid {
    grid-template-columns: 1fr;
  }

  .assistant-form-grid .field-checkbox,
  .assistant-form-grid label:has(#assistantBaseUrl),
  .assistant-form-grid label:has(#assistantModel),
  .assistant-form-grid label:has(#assistantApiKey),
  .assistant-form-grid label:has(#assistantTemperature),
  .assistant-form-grid label:has(#assistantMaxTokens) {
    grid-column: 1;
  }

  .split.grow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .split.grow .account-role-badge {
    justify-content: center;
  }

  .split.grow .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 6px;
    min-height: 0;
  }

  .section-head .section-title {
    min-height: 0;
    line-height: 1.3;
  }

  .section-head .field-help {
    width: 100%;
  }

  #assistantSystemPrompt,
  #automationReply,
  #quickReplyText {
    min-height: 120px;
  }

  .admin-create-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .admin-create-form .btn {
    width: 100%;
  }

  .admin-table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .admin-table {
    display: block;
    min-width: 0;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tbody {
    display: grid;
    gap: 12px;
  }

  .admin-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px 12px;
    padding: 17px;
    border: 1px solid rgba(16, 24, 40, 0.1);
    border-radius: 14px;
    background: #fff;
  }

  .admin-table td,
  .admin-table td:first-child,
  .admin-table td:last-child {
    display: grid;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .admin-table td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(16, 24, 40, 0.08);
  }

  .admin-table td:first-child strong,
  .admin-table td:first-child small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-table td:nth-child(2)::before,
  .admin-table td:nth-child(3)::before,
  .admin-table td:nth-child(4)::before {
    margin-bottom: 3px;
    color: #98a2b3;
    font-size: 11px;
  }

  .admin-table td:nth-child(2)::before { content: "角色"; }
  .admin-table td:nth-child(3)::before { content: "狀態"; }
  .admin-table td:nth-child(4)::before { content: "創建時間"; }

  .admin-table td:nth-child(4) {
    grid-column: 1 / -1;
  }

  .admin-table td.admin-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 2px;
  }

  .admin-table td.admin-actions .btn {
    flex: 1 1 120px;
  }
}

/* Final auth overrides: keep the authentication views aligned with the
   monochrome homepage after the legacy responsive rules above. */
@media (min-width: 801px) {
  .auth-view {
    padding: 38px 28px;
    background: #f5f5f3;
  }

  .auth-shell,
  .auth-shell:has(#registerForm:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(250px, .82fr) minmax(420px, 1.18fr);
    align-items: center;
    gap: clamp(52px, 7vw, 92px);
    width: min(100%, 1000px);
    margin: auto;
    padding: 56px 64px;
    border: 0;
    border-radius: 28px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(17, 17, 17, .09);
  }

  .auth-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    align-self: start;
    justify-self: start;
    gap: 22px;
    margin: 0;
  }

  .auth-logo {
    width: 58px;
    height: 58px;
    box-shadow: none;
  }

  .auth-kicker {
    margin-bottom: 8px;
    color: #777;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .14em;
  }

  .auth-brand h1 {
    color: #111;
    font-size: clamp(34px, 4vw, 48px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -.045em;
  }

  .auth-brand p:last-child {
    color: #777;
  }

  .auth-form {
    grid-column: 2;
    align-self: center;
    gap: 14px;
  }

  #registerForm,
  #resetForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
  }

  #registerForm > .verification-row,
  #registerForm > #registerTencentCaptcha,
  #registerForm > .agreement-open,
  #registerForm > .check-row,
  #registerForm > .auth-error,
  #registerForm > .auth-submit,
  #registerForm > .auth-links,
  #resetForm > .field:first-child,
  #resetForm > .verification-row,
  #resetForm > #resetTencentCaptcha,
  #resetForm > .auth-error,
  #resetForm > .auth-submit,
  #resetForm > .auth-links {
    grid-column: 1 / -1;
  }

  .auth-form .field-label {
    color: #444;
    font-size: 13px;
    font-weight: 500;
  }

  .auth-form input,
  .auth-form select {
    min-height: 46px;
    border-color: #d8d8d4;
    border-radius: 10px;
    color: #111;
    background: #fff;
  }

  .auth-form input:hover,
  .auth-form select:hover {
    border-color: #999;
  }

  .auth-form input:focus,
  .auth-form select:focus {
    border-color: #111;
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .08);
  }

  .auth-submit,
  .btn.primary,
  .send {
    color: #fff;
    background: #111;
    border-color: #111;
    box-shadow: 0 10px 24px rgba(17, 17, 17, .14);
  }

  .auth-submit:hover,
  .btn.primary:hover,
  .send:hover:not(:disabled) {
    color: #fff;
    background: #2b2b2b;
    border-color: #2b2b2b;
    box-shadow: 0 12px 28px rgba(17, 17, 17, .18);
  }

  .auth-links button,
  .agreement-open {
    color: #111;
    text-decoration-color: rgba(17, 17, 17, .28);
  }

  .auth-links button:hover,
  .agreement-open:hover {
    color: #555;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 132px;
    align-items: end;
    gap: 10px;
  }

  .verification-row > .field {
    min-width: 0;
  }

  .verification-row > .btn {
    align-self: end;
    width: 132px;
    height: 46px;
    margin: 0;
    padding-inline: 10px;
    border-radius: 10px;
    white-space: nowrap;
  }

  .check-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    color: #555;
    line-height: 1.5;
  }

  .check-row input {
    width: 16px !important;
    height: 16px;
    margin: 2px 0 0;
  }

  .check-row span {
    min-width: 0;
  }
}

@media (max-width: 800px) {
  .auth-view {
    min-height: 100dvh;
    padding: 18px 14px;
    background: #f5f5f3;
  }

  .auth-shell,
  .auth-shell:has(#registerForm:not([hidden])) {
    display: grid;
    grid-template-columns: 1fr;
    width: min(100%, 560px);
    margin: auto;
    padding: 30px 24px;
    border: 0;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 18px 54px rgba(17, 17, 17, .09);
  }

  .auth-brand {
    margin-bottom: 26px;
  }

  .auth-form {
    grid-column: 1;
  }

  #registerForm,
  #resetForm {
    grid-template-columns: 1fr;
  }

  #registerForm > *,
  #resetForm > * {
    grid-column: 1;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 118px;
    align-items: end;
  }

  .verification-row > .btn {
    width: 118px;
    height: 46px;
    padding-inline: 8px;
    font-size: 12px;
  }

  .check-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  .check-row input {
    margin-top: 2px;
  }
}

/* Pixel alignment pass for the verification controls and checkbox inputs. */
@media (min-width: 801px) {
  .auth-shell .verification-row {
    align-items: start;
  }

  .auth-shell .verification-row > .btn {
    align-self: start;
    margin-top: 25px;
  }

  .auth-shell .check-row input {
    width: 16px !important;
    min-width: 16px;
    height: 16px;
    min-height: 16px;
  }
}

@media (max-width: 800px) {
  .auth-shell .verification-row {
    align-items: start;
  }

  .auth-shell .verification-row > .btn {
    align-self: start;
    margin-top: 25px;
  }

  .auth-shell .check-row input {
    min-height: 16px;
  }
}

.auth-shell .agreement-inline-link {
  display: inline;
  min-height: 0;
  margin: 0;
  padding: 0;
  color: #111;
  border: 0;
  background: transparent;
  font: inherit;
  line-height: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.auth-shell .agreement-inline-link:hover {
  color: #555;
}

/* Keep the authentication actions monochrome on every breakpoint. */
.auth-shell .auth-submit {
  color: #fff;
  background: #111;
  border-color: #111;
  box-shadow: 0 10px 24px rgba(17, 17, 17, .14);
}

.auth-shell .auth-submit:hover:not(:disabled) {
  color: #fff;
  background: #2b2b2b;
  border-color: #2b2b2b;
}

/* The agreement date follows the title instead of occupying a separate row. */
.agreement-head .agreement-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.agreement-head .agreement-date {
  display: inline;
  margin: 0;
  color: #8c94a7;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

/* Long registration/reset forms must start inside the viewport and scroll
   downward instead of being vertically centered with their top clipped. */
@media (max-width: 800px) {
  .auth-view {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .auth-shell,
  .auth-shell:has(#registerForm:not([hidden])) {
    margin: 0 auto;
  }

  .auth-shell .verification-row > .btn {
    height: 44px;
    min-height: 44px;
  }
}

/* Final settings surface: one setting per row, with the downloader layout
   treated as the source of truth for spacing, grouping, and controls. */
.settings-layout {
  width: min(720px, 100%);
  margin-inline: auto;
  padding: 36px clamp(24px, 7vw, 72px) 80px;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.settings-stack > .client-section {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #f4f4f5;
  box-shadow: none;
}

.settings-stack > .client-section > .section-title,
.settings-stack > .client-section > .section-head {
  margin: 0;
  padding: 18px 16px 8px;
}

.settings-stack > .client-section .field.field-row,
.settings-stack > .client-section .assistant-form-grid .field,
.settings-stack > .client-section .assistant-form > .field,
.settings-stack > .client-section .quick-reply-form > .field,
.settings-stack > .client-section .inline-setting-form > .field,
.settings-stack > .client-section .password-form > .field,
.settings-stack > .client-section .password-form .field.field-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  min-height: 52px;
  margin: 0;
  padding: 8px 16px;
  border: 0;
  border-bottom: 1px solid rgba(17, 17, 17, .08);
  background: transparent;
}

.settings-stack > .client-section .field.field-row:last-child,
.settings-stack > .client-section .assistant-form-grid .field:last-child,
.settings-stack > .client-section .assistant-form > .field:last-child,
.settings-stack > .client-section .quick-reply-form > .field:last-child,
.settings-stack > .client-section .inline-setting-form > .field:last-child,
.settings-stack > .client-section .password-form > .field:last-child {
  border-bottom: 0;
}

.settings-stack > .client-section .field.field-row > label,
.settings-stack > .client-section .assistant-form-grid .field > label,
.settings-stack > .client-section .assistant-form > .field > label,
.settings-stack > .client-section .quick-reply-form > .field > label,
.settings-stack > .client-section .inline-setting-form > .field > label,
.settings-stack > .client-section .password-form > .field > label {
  margin: 0;
  color: #4e5562;
  font-size: 14px;
  line-height: 1.4;
}

.settings-stack > .client-section .field.field-row > :not(label),
.settings-stack > .client-section .assistant-form-grid .field > :not(label),
.settings-stack > .client-section .assistant-form > .field > :not(label),
.settings-stack > .client-section .quick-reply-form > .field > :not(label),
.settings-stack > .client-section .inline-setting-form > .field > :not(label),
.settings-stack > .client-section .password-form > .field > :not(label) {
  min-width: 0;
}

.settings-stack > .client-section input,
.settings-stack > .client-section select,
.settings-stack > .client-section textarea {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid #dedee1;
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
}

.settings-stack > .client-section textarea {
  min-height: 88px;
  padding-block: 9px;
  resize: vertical;
}

.settings-stack > .client-section .assistant-form-grid,
.settings-stack > .client-section .assistant-form,
.settings-stack > .client-section .quick-reply-form,
.settings-stack > .client-section .inline-setting-form,
.settings-stack > .client-section .password-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-stack > .client-section .check-row,
.settings-stack > .client-section .setting-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(17, 17, 17, .08);
}

.settings-stack > .client-section .check-row input,
.settings-stack > .client-section .setting-check input {
  flex: 0 0 auto;
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 0;
}

.settings-stack > .client-section .setting-actions,
.settings-stack > .client-section .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px 16px;
}

.agreement-copy h2 {
  margin: 30px 0 12px;
  padding-top: 6px;
  color: #111827;
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: .02em;
}

.agreement-copy h3 {
  margin: 20px 0 8px;
  color: #202938;
  font-size: 17px;
  line-height: 1.5;
  font-weight: 650;
}

.agreement-copy .legal-subsection {
  margin: 0 0 10px;
  padding-left: 14px;
  color: #5e6878;
  border-left: 2px solid #d9dee8;
  font-size: 14px;
  line-height: 1.8;
}

.agreement-copy .legal-subsection strong {
  color: #303a4a;
  font-weight: 650;
}

@media (max-width: 680px) {
  .settings-layout {
    width: 100%;
    padding: 24px 14px 64px;
  }

  .settings-stack > .client-section .field.field-row,
  .settings-stack > .client-section .assistant-form-grid .field,
  .settings-stack > .client-section .assistant-form > .field,
  .settings-stack > .client-section .quick-reply-form > .field,
  .settings-stack > .client-section .inline-setting-form > .field,
  .settings-stack > .client-section .password-form > .field {
    grid-template-columns: 88px minmax(0, 1fr);
  }
}

/* Final source-order override: keep the exact downloader side margins. */
.settings-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100% !important;
  min-height: 100%;
  margin: 0;
  padding: 36px clamp(72px, 18vw, 240px) 80px !important;
}

.settings-hero,
.settings-stack {
  width: 100%;
  max-width: 720px;
}

.settings-hero {
  margin: 0 auto 18px;
  padding-bottom: 8px;
}

.settings-stack {
  display: grid;
  align-content: start;
  gap: 4px;
  margin-top: 0;
}

@media (max-width: 1280px) {
  .settings-layout {
    padding-left: clamp(40px, 10vw, 120px) !important;
    padding-right: clamp(40px, 10vw, 120px) !important;
  }
}

@media (max-width: 900px) {
  .settings-layout {
    padding: 28px 20px 64px !important;
  }
}

@media (max-width: 680px) {
  .settings-layout {
    padding: 24px 14px 64px !important;
  }
}

/*
 * Downloader source parity — settings content only.
 * Keep the existing Bouquet sidebar untouched.  These values are copied
 * from Desktop/downloader/webui/assets/styles.css: centered document shell,
 * soft grouped surfaces, 52px rows, and 300px right-aligned controls.
 */
#viewSettings {
  min-width: 0;
  min-height: 0;
}

#viewSettings > #scrollSettings {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

#viewSettings > #scrollSettings::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#viewSettings > #scrollSettings::-webkit-scrollbar-track {
  background: transparent;
}

#viewSettings > #scrollSettings::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

#viewSettings > #scrollSettings::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
  background-clip: padding-box;
}

#viewSettings .settings-layout.settings-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100% !important;
  min-height: 100%;
  margin: 0;
  padding: 36px clamp(72px, 18vw, 240px) 80px !important;
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei UI", sans-serif;
}

#viewSettings .settings-hero.md-settings-header,
#viewSettings .settings-stack.md-settings-container {
  width: 100%;
  max-width: 720px;
}

#viewSettings .settings-hero.md-settings-header {
  display: block;
  margin: 0 0 8px;
  padding: 0;
}

#viewSettings .settings-hero.md-settings-header h1 {
  margin: 0 0 2px;
  color: #0d0d0d;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

#viewSettings .settings-hero.md-settings-header p {
  margin: 0;
  color: #8e8e93;
  font-size: 13px;
  line-height: 1.5;
}

#viewSettings .settings-stack.md-settings-container {
  display: flex;
  flex-direction: column;
  align-content: start;
  gap: 4px;
  margin: 0;
  padding-bottom: 40px;
}

#viewSettings .md-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 6px;
  padding-left: 4px;
  color: #8e8e93;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

#viewSettings .md-section-title-with-help .field-help {
  margin: 0;
  color: #8e8e93;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
}

#viewSettings .client-section.md-settings-card {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #f4f4f5;
  border: 0;
  border-radius: 14px;
  box-shadow: none;
}

#viewSettings .client-section.md-settings-card .field-stack,
#viewSettings .client-section.md-settings-card .assistant-form,
#viewSettings .client-section.md-settings-card .quick-reply-form,
#viewSettings .client-section.md-settings-card .inline-setting-form,
#viewSettings .client-section.md-settings-card .assistant-form-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  margin: 0;
}

#viewSettings .client-section.md-settings-card .field.field-row,
#viewSettings .client-section.md-settings-card .assistant-form-grid > .field:not(.field-checkbox),
#viewSettings .client-section.md-settings-card .assistant-form > .field:not(.field-checkbox),
#viewSettings .client-section.md-settings-card .quick-reply-form > .field,
#viewSettings .client-section.md-settings-card .inline-setting-form > .field {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  width: 100%;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 0;
  background: transparent;
  transition: background 140ms cubic-bezier(0.4, 0, 0.2, 1);
}

#viewSettings .client-section.md-settings-card .field.field-row:hover,
#viewSettings .client-section.md-settings-card .assistant-form-grid > .field:not(.field-checkbox):hover,
#viewSettings .client-section.md-settings-card .assistant-form > .field:not(.field-checkbox):hover,
#viewSettings .client-section.md-settings-card .quick-reply-form > .field:hover,
#viewSettings .client-section.md-settings-card .inline-setting-form > .field:hover {
  background: rgba(0, 0, 0, 0.025);
}

#viewSettings .client-section.md-settings-card .field-label {
  min-width: 0;
  margin: 0;
  padding: 0;
  color: #1e293b;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

#viewSettings .client-section.md-settings-card .field.field-row > input,
#viewSettings .client-section.md-settings-card .field.field-row > select,
#viewSettings .client-section.md-settings-card .field.field-row > .split,
#viewSettings .client-section.md-settings-card .assistant-form-grid > .field > input,
#viewSettings .client-section.md-settings-card .assistant-form > .field > input,
#viewSettings .client-section.md-settings-card .quick-reply-form > .field > input,
#viewSettings .client-section.md-settings-card .inline-setting-form > .field > input {
  justify-self: end;
  width: 300px;
  min-width: 0;
  max-width: 100%;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #fff;
  color: #0d0d0d;
  font-size: 13.5px;
  font-weight: 400;
  box-shadow: none;
  outline: none;
  box-sizing: border-box;
}

#viewSettings .client-section.md-settings-card .field.field-row > select,
#viewSettings .client-section.md-settings-card .assistant-form-grid > .field > input,
#viewSettings .client-section.md-settings-card .assistant-form > .field > input,
#viewSettings .client-section.md-settings-card .quick-reply-form > .field > input,
#viewSettings .client-section.md-settings-card .inline-setting-form > .field > input {
  appearance: none;
}

#viewSettings .client-section.md-settings-card .field.field-row > input:focus,
#viewSettings .client-section.md-settings-card .field.field-row > select:focus,
#viewSettings .client-section.md-settings-card .assistant-form-grid > .field > input:focus,
#viewSettings .client-section.md-settings-card .assistant-form > .field > input:focus,
#viewSettings .client-section.md-settings-card .quick-reply-form > .field > input:focus,
#viewSettings .client-section.md-settings-card .inline-setting-form > .field > input:focus {
  border-color: #0d0d0d;
  box-shadow: none;
}

#viewSettings .client-section.md-settings-card .split.grow {
  display: flex;
  align-items: center;
  justify-self: end;
  width: 300px;
  min-width: 0;
  gap: 8px;
}

#viewSettings .client-section.md-settings-card .split.grow input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

#viewSettings .client-section.md-settings-card .field textarea,
#viewSettings .client-section.md-settings-card textarea {
  justify-self: end;
  width: 300px;
  min-width: 0;
  max-width: 100%;
  min-height: 88px;
  padding: 9px 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #fff;
  color: #0d0d0d;
  font-size: 13.5px;
  box-shadow: none;
  resize: vertical;
}

#viewSettings .client-section.md-settings-card .assistant-form > .field:has(textarea),
#viewSettings .client-section.md-settings-card .quick-reply-form > .field:has(textarea) {
  height: auto;
  min-height: 112px;
  max-height: none;
  align-items: start;
  padding-top: 12px;
  padding-bottom: 12px;
}

#viewSettings .client-section.md-settings-card .app-key-row {
  height: auto;
  min-height: 76px;
  max-height: none;
  align-items: start;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* The source page uses a tall row whenever a setting has two control lines. */
#viewSettings .client-section.md-settings-card .field.field-row.app-key-row {
  height: auto;
  min-height: 76px;
  max-height: none;
  align-items: start;
  padding-top: 12px;
  padding-bottom: 12px;
}

#viewSettings .client-section.md-settings-card .app-key-setting,
#viewSettings .client-section.md-settings-card .app-key-control,
#viewSettings .client-section.md-settings-card .app-key-actions {
  width: 300px;
  min-width: 0;
}

#viewSettings .client-section.md-settings-card .app-key-control,
#viewSettings .client-section.md-settings-card .app-key-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

#viewSettings .client-section.md-settings-card .app-key-control input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

#viewSettings .client-section.md-settings-card .app-key-actions {
  margin-top: 8px;
}

#viewSettings .client-section.md-settings-card .btn,
#viewSettings .client-section.md-settings-card .btn.compact {
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13.5px;
}

#viewSettings .client-section.md-settings-card .btn.primary {
  color: #fff;
  background: #0d0d0d;
  border-color: #0d0d0d;
}

#viewSettings .client-section.md-settings-card .btn.primary:hover {
  color: #fff;
  background: #2a2a2a;
  border-color: #2a2a2a;
}

#viewSettings .client-section.md-settings-card .btn.ghost {
  color: #0d0d0d;
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
}

#viewSettings .client-section.md-settings-card .field.field-checkbox,
#viewSettings .client-section.md-settings-card .check-row,
#viewSettings .client-section.md-settings-card .setting-check {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  min-height: 52px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  background: transparent;
}

#viewSettings .client-section.md-settings-card .field.field-checkbox input,
#viewSettings .client-section.md-settings-card .check-row input,
#viewSettings .client-section.md-settings-card .setting-check input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: #0d0d0d;
}

#viewSettings .client-section.md-settings-card .field.field-checkbox span,
#viewSettings .client-section.md-settings-card .check-row span,
#viewSettings .client-section.md-settings-card .setting-check span {
  color: #1e293b;
  font-size: 14px;
  line-height: 1.4;
}

#viewSettings .client-section.md-settings-card .setting-actions,
#viewSettings .client-section.md-settings-card .form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 52px;
  margin: 0;
  padding: 8px 16px;
}

#viewSettings .client-section.md-settings-card .field-help {
  color: #8e8e93;
  font-size: 12px;
  line-height: 1.5;
}

#viewSettings .client-section.md-settings-card .field-stack > .field-help {
  margin: 0;
  padding: 10px 16px 12px;
}

@media (max-width: 1280px) {
  #viewSettings .settings-layout.settings-shell {
    padding-left: clamp(40px, 10vw, 120px) !important;
    padding-right: clamp(40px, 10vw, 120px) !important;
  }
}

@media (max-width: 900px) {
  #viewSettings .settings-layout.settings-shell {
    padding: 28px 20px 64px !important;
  }
}

@media (max-width: 680px) {
  #viewSettings .settings-layout.settings-shell {
    padding: 24px 14px 64px !important;
  }

  #viewSettings .md-section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  #viewSettings .client-section.md-settings-card .field.field-row,
  #viewSettings .client-section.md-settings-card .assistant-form-grid > .field:not(.field-checkbox),
  #viewSettings .client-section.md-settings-card .assistant-form > .field:not(.field-checkbox),
  #viewSettings .client-section.md-settings-card .quick-reply-form > .field,
  #viewSettings .client-section.md-settings-card .inline-setting-form > .field {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  #viewSettings .client-section.md-settings-card .field.field-row > input,
  #viewSettings .client-section.md-settings-card .field.field-row > select,
  #viewSettings .client-section.md-settings-card .field.field-row > .split,
  #viewSettings .client-section.md-settings-card .field textarea,
  #viewSettings .client-section.md-settings-card textarea,
  #viewSettings .client-section.md-settings-card .app-key-setting,
  #viewSettings .client-section.md-settings-card .app-key-control,
  #viewSettings .client-section.md-settings-card .app-key-actions {
    width: 100%;
  }
}

/* Final modal overrides: keep the secondary settings view above the current
   workbench page, while leaving the existing sidebar untouched. */
body.settings-subpage-open {
  overflow: hidden;
}

#viewSettings .settings-subpage {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 24px;
  overflow: auto;
}

#viewSettings .settings-subpage[hidden] {
  display: none !important;
}

#viewSettings .settings-subpage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 35, 45, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#viewSettings .settings-subpage-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(760px, calc(100dvh - 48px));
  min-height: 0;
  overflow: hidden;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 26px 90px rgba(25, 32, 54, 0.28);
}

#viewSettings .settings-subpage-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  margin: 0;
  padding: 0 24px;
  border-bottom: 1px solid #e7e9f0;
  box-sizing: border-box;
}

#viewSettings .settings-subpage-header h2 {
  grid-column: auto;
  margin: 0;
  color: #0d0d0d;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

#viewSettings .settings-close-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #30343b;
  background: #f1f2f4;
  cursor: pointer;
}

#viewSettings .settings-close-button:hover {
  background: #e7e9ed;
}

#viewSettings .settings-close-button svg {
  width: 19px;
  height: 19px;
}

#viewSettings .settings-subpage-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 24px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

#viewSettings .settings-subpage-content::-webkit-scrollbar {
  width: 10px;
}

#viewSettings .settings-subpage-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

#viewSettings .settings-subpage-content .client-section.md-settings-card {
  width: 100%;
  max-width: none;
}

#viewSettings #assistantSystemPrompt {
  height: 36px;
  min-height: 36px;
  resize: none;
}

@media (max-width: 680px) {
  #viewSettings .settings-subpage {
    padding: 12px;
  }

  #viewSettings .settings-subpage-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  #viewSettings .settings-subpage-header {
    min-height: 64px;
    padding-inline: 16px;
  }

  #viewSettings .settings-subpage-content {
    padding: 14px 12px 16px;
  }

  #viewSettings #assistantSystemPrompt {
    height: 36px;
    min-height: 36px;
  }
}

/* Workbench-only finish: use the browser/system UI font.  Code surfaces keep
   their dedicated monospace stack through the existing InkFlow styles. */
body:not(.is-auth-view) .app {
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif;
  font-family: var(--font);
}

/* Authentication pages use the same self-hosted display/UI face as bouquet.chat. */
body.is-auth-view .app {
  --font: "Bouquet App", "Noto Serif TC", "Songti TC", serif;
  font-family: var(--font);
}

/* Tool buttons change tone on hover, never grow a border or frame. */
#viewChat .tool-chip:hover,
#viewChat .tool-chip:active,
#viewChat .tool-chip.is-on {
  border-color: transparent !important;
  box-shadow: none !important;
}

#viewChat .tool-chip:focus-visible {
  outline: 2px solid rgba(23, 105, 245, 0.35);
  outline-offset: 2px;
}

/* AI reply generation stays visually still; only the disabled state changes. */
#viewChat .tool-chip.is-loading svg {
  animation: none !important;
  transform: none !important;
}

/* The conversation surface is the drop target for image/video/audio files. */
#viewChat .thread {
  position: relative;
}

#viewChat .thread.is-drop-target::after {
  content: "拖放圖片、視頻或音頻至此";
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(23, 105, 245, 0.42);
  border-radius: 18px;
  background: rgba(245, 248, 255, 0.9);
  color: #174caa;
  font-size: 14px;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 5;
}

.quick-reply-option {
  grid-template-columns: auto minmax(0, 1fr) !important;
  align-items: center;
}

/* System notifications use the same compact grouped-row treatment as the
   existing settings cards. */
#viewSettings .notification-settings-card {
  padding: 0;
}

#viewSettings .notification-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  height: 52px;
  min-height: 52px;
  padding: 8px 16px;
  box-sizing: border-box;
}

#viewSettings .notification-settings-copy strong {
  color: #1e293b;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

#viewSettings .notification-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 40px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  box-shadow: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

#viewSettings .notification-switch.is-on {
  background: #1c1b18;
}

#viewSettings .notification-switch:focus-visible {
  outline: 2px solid rgba(91, 127, 227, 0.45);
  outline-offset: 3px;
}

#viewSettings .notification-switch:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#viewSettings .notification-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 160ms ease;
}

#viewSettings .notification-switch.is-on::after {
  transform: translateX(16px);
}

@media (max-width: 680px) {
  #viewSettings .notification-settings-row {
    gap: 12px;
    padding-inline: 12px;
  }
}

.quick-reply-option kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 22px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  color: #7381a3;
  background: #edf1fb;
  font: 11px/1.2 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Shortcut help is a real modal surface, independent of the settings modal. */
body.shortcut-dialog-open {
  overflow: hidden;
}

.shortcut-dialog {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  box-sizing: border-box;
}

.shortcut-dialog[hidden] {
  display: none !important;
}

.shortcut-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 31, 46, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.shortcut-dialog-card {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(720px, calc(100dvh - 48px));
  overflow: hidden;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 26px 90px rgba(25, 32, 54, 0.28);
}

.shortcut-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 24px;
  border-bottom: 1px solid #e7e9f0;
}

.shortcut-dialog-head h2 {
  margin: 0;
  color: #17233a;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.shortcut-dialog-close {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #30343b;
  background: #f1f2f4;
  cursor: pointer;
}

.shortcut-dialog-close:hover {
  background: #e7e9ed;
}

.shortcut-dialog-close svg {
  width: 19px;
  height: 19px;
}

.shortcut-dialog-body {
  display: grid;
  gap: 0;
  max-height: min(550px, calc(100dvh - 170px));
  overflow: auto;
  padding: 10px 24px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

.shortcut-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(108px, auto) minmax(108px, auto);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-bottom: 1px solid rgba(16, 24, 40, 0.07);
  color: #344054;
  font-size: 14px;
}

.shortcut-row:last-child {
  border-bottom: 0;
}

.shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #dfe3eb;
  border-radius: 8px;
  color: #52627f;
  background: #f8f9fc;
  font: 12px/1.2 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  white-space: nowrap;
}

.shortcut-dialog-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 24px 20px;
  color: #98a2b3;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 680px) {
  .shortcut-dialog {
    padding: 12px;
  }

  .shortcut-dialog-card {
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  .shortcut-dialog-head {
    min-height: 64px;
    padding-inline: 16px;
  }

  .shortcut-dialog-body {
    padding: 8px 16px 12px;
  }

  .shortcut-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    font-size: 13px;
  }

  .shortcut-row kbd {
    min-height: 28px;
    padding-inline: 6px;
    font-size: 10px;
  }

  .shortcut-dialog-legend {
    padding-inline: 16px;
  }
}

/* Keep focus feedback on the composer shell; the editable surface itself
   must remain borderless and free of an inner focus frame. */
#viewChat .composer-shell textarea,
#viewChat .composer-shell textarea:focus,
#viewChat .composer-shell textarea:focus-visible {
  border: 0 !important;
  outline: 0 !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
}

/* Keep the original conversation direction: caller on the left, human
   response on the right. */
#viewChat .messages .msg--user {
  justify-content: flex-start;
}

/* Last-line guard for every static timeline render. It deliberately wins over
   legacy or later message-specific animation declarations without disabling
   the one explicit first-entry animation. */
#viewChat .messages.is-message-static > .msg,
#viewChat .messages.is-message-static > .msg.msg-enter {
  animation: none !important;
  will-change: auto;
}

#viewChat .messages .msg--user .msg-col {
  align-items: flex-start;
}

#viewChat .messages .msg--assistant {
  grid-template-columns: minmax(0, 1fr) 32px;
}

#viewChat .messages .msg--assistant .msg-col {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#viewChat .messages .msg--assistant .msg-avatar {
  grid-column: 2;
  grid-row: 1;
}

#viewChat .messages .msg--assistant .msg-role {
  width: 100%;
  text-align: right;
}

#viewChat .messages .msg--assistant .msg-body {
  width: fit-content;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--assistant-bg);
  box-shadow: none;
  border: 0;
  text-align: left;
}

/* Hover timestamps sit on the outside edge of the metadata row: caller after
   the row, responder before it. The normal metadata row stays unchanged. */
.msg-bubble-group {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.msg-bubble-group--user {
  align-items: flex-start;
}

.msg-bubble-group--assistant {
  align-items: flex-end;
}

.msg-bubble-head {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 0;
  gap: 8px;
}

.msg-bubble-head--user {
  justify-content: flex-start;
}

.msg-bubble-head--assistant {
  justify-content: flex-end;
  margin-bottom: 6px;
}

#viewChat .messages .msg--assistant .msg-bubble-head .msg-role {
  width: auto;
  margin: 0;
}

.msg-bubble-line {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.msg-bubble-line--user {
  justify-content: flex-start;
}

.msg-bubble-line--assistant {
  justify-content: flex-end;
}

.msg-hover-time {
  display: inline-block;
  flex: 0 0 auto;
  max-width: 0;
  max-height: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 0;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: max-width 0.16s ease, max-height 0.16s ease, line-height 0.16s ease, opacity 0.16s ease;
}

.msg:hover .msg-hover-time,
.msg:focus-within .msg-hover-time {
  max-width: 22rem;
  max-height: 2em;
  line-height: 1.35;
  opacity: 1;
}

/* responder-profile-link-v1: a reply avatar opens that responder's public
   account page while preserving the existing grid footprint and circular crop. */
#viewChat .messages .msg-avatar--link {
  display: block;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

#viewChat .messages .msg-avatar--link:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(20, 18, 14, 0.14), inset 0 0 0 1px rgba(20, 18, 14, 0.1);
}

#viewChat .messages .msg-avatar--link:focus-visible {
  outline: 2px solid rgba(79, 100, 155, 0.55);
  outline-offset: 3px;
}

/* The virtual-list performance rule uses block layout, so restore a real
   vertical gap between each independent conversation surface. */
.sidebar-scroll .conv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-scroll .conv {
  height: auto;
  min-height: 76px;
}

/* Shared-pool state is intentionally a single dot in the list.  The full
   explanation lives beneath the active conversation title. */
.conv-status.is-connected {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}
.conv-status.is-lost {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.conv-status.is-locked {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}
.conv-status.is-completed {
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.12);
}

.chat-bar {
  height: 70px;
  min-height: 70px;
}
.chat-heading {
  min-width: 0;
  max-width: min(72vw, 42rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.chat-heading .top-title {
  max-width: 100%;
}
.top-status {
  min-height: 15px;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: #8b96aa;
  font-size: 11px;
  font-weight: 500;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-status[data-state="connected"] { color: #27915a; }
.top-status[data-state="lost"] { color: #c34f55; }
.top-status[data-state="locked"] { color: #b77716; }
.top-status[data-state="completed"] { color: #66748b; }
/* composer-click-lock-v1: lock state is shown in the header; no standalone control. */
.top-status[data-state="locking"] { color: #b77716; }

/* thinking-polish-v1: make responder reasoning a quiet, readable surface
   inside the assistant message instead of a flat block with a text glyph. */
#viewChat .messages .thinking-panel {
  width: min(100%, 38rem);
  margin: 0 0 12px;
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, 0.09);
  border-radius: 14px;
  background: linear-gradient(180deg, #f8f9fb 0%, #f3f4f6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82), 0 4px 16px rgba(17, 24, 39, 0.035);
}

#viewChat .messages .thinking-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 11px;
  border-radius: 13px;
  color: #596273;
  transition: background 0.18s ease, color 0.18s ease;
}

#viewChat .messages .thinking-head:hover,
#viewChat .messages .thinking-head:focus-visible {
  color: #303846;
  background: rgba(255, 255, 255, 0.62);
}

#viewChat .messages .thinking-head:focus-visible {
  outline: 2px solid rgba(17, 24, 39, 0.18);
  outline-offset: -2px;
}

#viewChat .messages .thinking-title {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

#viewChat .messages .thinking-title svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: #6d7788;
  stroke-width: 1.8;
}

#viewChat .messages .thinking-state {
  color: #9aa2af;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

#viewChat .messages .thinking-panel.is-live .thinking-state {
  color: #687383;
}

#viewChat .messages .thinking-panel.is-live .thinking-state::before {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 5px 1px 0;
  border-radius: 50%;
  background: #737e8e;
  content: "";
  animation: thinkingPulse 1.45s ease-in-out infinite;
}

#viewChat .messages .thinking-head .fold-chevron {
  width: 20px;
  height: 20px;
  color: #8b94a2;
  transition: transform 0.22s ease, color 0.18s ease;
}

#viewChat .messages .thinking-head .fold-chevron svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
}

#viewChat .messages .thinking-panel .fold-body {
  display: grid;
  grid-template-rows: 0fr;
  max-height: 0;
  padding: 0 12px;
  opacity: 0;
  overflow: hidden;
  mask-image: none;
  -webkit-mask-image: none;
  transition: grid-template-rows 0.28s ease, max-height 0.28s ease, padding 0.28s ease, opacity 0.2s ease;
}

#viewChat .messages .thinking-panel.is-expanded .fold-body {
  grid-template-rows: 1fr;
  max-height: 260px;
  padding: 0 12px 12px;
  opacity: 1;
  overflow: hidden;
}

#viewChat .messages .thinking-content {
  min-height: 0;
  max-height: 236px;
  padding: 0 1px;
  color: #687384;
  font-size: 12px;
  line-height: 1.72;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(104, 115, 132, 0.26) transparent;
}

#viewChat .messages .thinking-content.md p {
  margin: 0 0 0.55em;
}

#viewChat .messages .thinking-content.md > :last-child {
  margin-bottom: 0;
}

#viewChat .messages .thinking-content code {
  color: #596477;
  background: rgba(17, 24, 39, 0.055);
}

#viewChat .messages .thinking-panel.is-live {
  border-color: rgba(17, 24, 39, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86), 0 5px 18px rgba(17, 24, 39, 0.045);
}

@keyframes thinkingPulse {
  0%,
  100% { opacity: 0.35; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  #viewChat .messages .thinking-panel.is-live .thinking-state::before,
  #viewChat .messages .thinking-head,
  #viewChat .messages .thinking-head .fold-chevron,
  #viewChat .messages .thinking-panel .fold-body {
    animation: none;
    transition: none;
  }
}

@media (max-width: 640px) {
  #viewChat .messages .thinking-panel {
    width: 100%;
  }

  #viewChat .messages .thinking-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #viewChat .messages .thinking-state {
    display: none;
  }
}

/* chat-code-layout-v1: regular code and reasoning share one compact, balanced
   margin inside the conversation bubble. The copied code surface keeps its
   original internal padding, typography, border, and radius. */
#viewChat .messages .msg-body.md > .inkflow-code-shell {
  margin: 0.65em 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#viewChat .messages .msg-body.md > .inkflow-code-shell:first-child {
  margin-top: 0;
}

#viewChat .messages .msg-body.md > .inkflow-code-shell:last-child {
  margin-bottom: 0;
}

#viewChat .messages .thinking-code-shell .inkflow-code-toolbar-actions {
  display: none;
}

/* thinking-wrap-v1: reasoning uses the same InkFlow code surface and spacing,
   but long lines must wrap inside the bubble instead of creating a second
   horizontal scrollport. Regular code blocks keep their source-preserving
   horizontal scrolling behavior. */
#viewChat .messages .thinking-code-shell {
  width: 100%;
  max-width: 100%;
  margin: 0.65em 0;
  box-sizing: border-box;
}

#viewChat .messages .thinking-code-shell pre {
  max-width: 100%;
  overflow-x: hidden !important;
  overflow-y: auto;
  box-sizing: border-box;
}

#viewChat .messages .thinking-code-shell pre code {
  min-width: 0 !important;
  max-width: 100%;
  white-space: pre-wrap !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* chat-code-borderless-v1: keep the copied InkFlow surface and typography,
   while removing visible frames from both ordinary code and thinking code. */
#viewChat .messages .inkflow-code-shell,
#viewChat .messages .inkflow-code-shell pre,
#viewChat .messages .inkflow-code-toolbar {
  border: 0 !important;
}

/* markdown-latex-rendering-v1: both caller and responder bubbles use the
   same CommonMark/GFM surface. Keep rich blocks readable inside the narrow
   message rail and let KaTeX/table content scroll locally when necessary. */
#viewChat .messages .msg-body.md {
  white-space: normal;
  overflow-wrap: anywhere;
}

#viewChat .messages .msg-body.md h1,
#viewChat .messages .msg-body.md h2,
#viewChat .messages .msg-body.md h3,
#viewChat .messages .msg-body.md h4,
#viewChat .messages .msg-body.md h5,
#viewChat .messages .msg-body.md h6 {
  color: var(--ink);
}

#viewChat .messages .msg-body.md h4,
#viewChat .messages .msg-body.md h5,
#viewChat .messages .msg-body.md h6 {
  margin: 0.8em 0 0.3em;
  font-size: 1em;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}

#viewChat .messages .msg-body.md hr {
  height: 0;
  margin: 1em 0;
  border: 0;
  border-top: 1px solid rgba(30, 35, 48, 0.2);
}

#viewChat .messages .msg-body.md del,
#viewChat .messages .msg-body.md s {
  text-decoration-thickness: 1px;
  text-decoration-color: currentColor;
}

#viewChat .messages .msg-body.md img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  border-radius: 9px;
  vertical-align: middle;
}

#viewChat .messages .msg-body.md p > img:only-child {
  display: block;
  margin: 0.35em 0;
}

#viewChat .messages .msg-body.md a {
  overflow-wrap: anywhere;
}

#viewChat .messages .msg-body.md .task-list-item {
  list-style: none;
  margin-left: -1.35em;
}

#viewChat .messages .msg-body.md .md-task-checkbox {
  width: 0.95em;
  height: 0.95em;
  margin: 0 0.45em 0 0;
  vertical-align: -0.1em;
  accent-color: var(--accent-ink);
}

/* markdown-latex-complete-v3: fit KaTeX into the message width without a
   formula scrollbar; tables retain their independent overflow behavior. */
#viewChat .messages .msg-body.md .md-math {
  color: inherit;
}

#viewChat .messages .msg-body.md .md-math--inline {
  display: inline-block;
  max-width: 100%;
  overflow: visible;
  vertical-align: middle;
}

#viewChat .messages .msg-body.md .md-math--block {
  display: block;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  margin: 0.7em 0;
  overflow: visible;
}

#viewChat .messages .msg-body.md .md-math--fit-block {
  display: block;
  width: 100%;
  margin: 0.35em 0;
  text-align: left;
}

#viewChat .messages .msg-body.md .md-math .katex-display {
  max-width: 100%;
  overflow: visible;
}

#viewChat .messages .msg-body.md .md-math .katex {
  max-width: 100%;
}

#viewChat .messages .msg-body.md .md-math--block:first-child {
  margin-top: 0;
}

#viewChat .messages .msg-body.md .md-math--block:last-child {
  margin-bottom: 0;
}

#viewChat .messages .msg-body.md .md-math .katex-display {
  margin: 0;
  padding: 0.15em 0;
  text-align: left;
}

#viewChat .messages .msg-body.md .md-math--fallback {
  white-space: pre-wrap;
}

#viewChat .messages .msg-body.md .md-table-wrap {
  width: 100%;
  box-sizing: border-box;
}

#viewChat .messages .msg-body.md .md-table-wrap table {
  table-layout: auto;
}

.conv__mention {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent, #1677ff);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

.top-status[data-state="mention"] {
  color: var(--accent, #1677ff);
}

/* Compact actions and token statistics below every normal message bubble. */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 4px 8px;
  width: fit-content;
  max-width: 100%;
  min-height: 26px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.msg--user .msg-meta {
  align-self: flex-start;
  justify-content: flex-start;
}

.msg--assistant .msg-meta {
  align-self: flex-end;
  justify-content: flex-end;
}

.msg-meta-actions,
.msg-meta-tokens {
  display: inline-flex;
  align-items: center;
}

.msg-meta-tokens {
  gap: 4px;
  white-space: nowrap;
}

.msg-meta-actions {
  gap: 1px;
}

.msg-meta-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.msg-meta-action:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
}

.msg-meta-action:active {
  transform: scale(0.94);
}

.msg-meta-action.is-copied {
  color: #1a7f37;
}

.msg-meta-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 640px) {
  .msg-meta {
    gap: 3px 6px;
    font-size: 10px;
  }

  .msg-meta-action {
    width: 24px;
    height: 24px;
  }
}

/* app-shell-visual-v3: the authenticated workspace uses the browser/system
   UI font; the public display face remains available for the auth surface. */
body:not(.is-auth-view) .app {
  --font-site: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif;
  --font-ui: var(--font-site);
  --font: var(--font-site);
  font-family: var(--font-site);
}

/* Keep the outer navigation and the conversation list visibly separate while
   staying within the quiet, borderless conversation-page palette. */
body:not(.is-auth-view) .app .global-nav {
  background: #f1f2f4;
}

body:not(.is-auth-view) .app.is-chat-section > #sidebar {
  background: #fbfbfc;
}

body:not(.is-auth-view) .app.is-chat-section > #sidebar .sidebar-foot {
  background: linear-gradient(180deg, transparent, #fbfbfc 18%);
}

body:not(.is-auth-view) .app .global-nav__item:hover {
  background: rgba(20, 25, 35, .06);
}

body:not(.is-auth-view) .app .global-nav__item.is-active {
  background: #e4e6e9;
}

/* app-home-launcher-v1: the home view is a quiet launcher, not a second
   copy of the conversation, notification, or account modules. */
.home-launch-section,
.home-workspace-section {
  margin-top: 30px;
}

.home-launch-grid,
.home-workspace-grid {
  display: grid;
  gap: 12px;
}

.home-launch-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-launch-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 22px;
  border: 0;
  border-radius: 18px;
  color: inherit;
  background: var(--user-bg);
  text-decoration: none;
  transition: background .18s ease, transform .18s var(--ease);
}

.home-launch-card:hover {
  background: #ececee;
  transform: translateY(-2px);
}

.home-launch-card:focus-visible {
  outline: 3px solid rgba(95, 104, 116, .25);
  outline-offset: 3px;
}

.home-launch-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: #616873;
  background: #fff;
}

.home-launch-icon svg {
  width: 20px;
  height: 20px;
}

.home-launch-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.home-launch-copy strong {
  color: #25282d;
  font-size: 15px;
  font-weight: 600;
}

.home-launch-copy span {
  color: #8a9098;
  font-size: 12px;
}

.home-launch-arrow {
  width: 17px;
  height: 17px;
  color: #8a9098;
}

.home-workspace-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-workspace-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 16px;
  border-radius: 15px;
  color: #4f555e;
  background: var(--user-bg);
}

.home-workspace-item svg {
  width: 17px;
  height: 17px;
  color: #7f858e;
}

.home-workspace-item span {
  font-size: 13px;
}

@media (max-width: 900px) {
  .home-launch-grid,
  .home-workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .home-launch-card {
    padding: 18px 16px;
  }

  .home-workspace-item {
    min-height: 52px;
  }
}

/* app-home-type-v1: keep home typography on the conversation-page scale. */
.home-brand-wordmark {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-regular);
  letter-spacing: -.02em;
  line-height: var(--lh-tight);
}

.home-brand-subtitle {
  margin-top: 6px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  letter-spacing: .04em;
  line-height: var(--lh-snug);
}

.home-welcome {
  margin: 16px 0 4px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
}

.home-identity-line,
.home-connection-state {
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
}

.home-identity-line strong {
  font-weight: var(--fw-medium);
}

.home-launch-section h1,
.home-workspace-section h2 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: 0;
}

.home-launch-copy strong {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}

.home-launch-copy span {
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
}

.home-workspace-item span {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}

/* Keep the verified account page controls in one quiet header row while the
   account content remains inside the AppShell's primary navigation. */
.app-account-view .account-module-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.app-account-view .account-module-actions .profile-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

@media (max-width: 560px) {
  .app-account-view .account-module-actions {
    gap: 10px;
  }

  .app-account-view .account-module-actions .profile-actions {
    gap: 10px;
  }

  .app-account-view .account-module-actions #accountLogout {
    padding-inline: 10px;
  }
}
