    :root {
      font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "PingFang SC", "Microsoft YaHei", sans-serif;
      --bg: #ffffff;
      --surface: #ffffff;
      --border: rgba(0, 0, 0, 0.08);
      --text: #1a1a1a;
      --muted: #6b7280;
      --user-bubble: #f5f5f5;
      --accent: #111827;
      --accent-soft: #f3f4f6;
      --radius-lg: 18px;
      --radius-xl: 22px;
      --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
      --shadow-composer: 0 4px 24px rgba(0, 0, 0, 0.06);
      --col-max: 48rem;
      /* 对话区宽松度（行高 / 段落 / 每条间距） */
      --bubble-line-height: 1.9;
      --bubble-padding-y: 0.85rem;
      --bubble-padding-x: 1.05rem;
      --turn-gap: 1.45rem;
      --md-p-margin-y: 0.5rem;
      --md-li-margin-y: 0.22rem;
      --md-heading-line-height: 1.42;
    }
    * { box-sizing: border-box; }
    html, body {
      height: 100%;
      margin: 0;
      color: var(--text);
      background: var(--bg);
      overflow: hidden;
    }
    .app {
      height: 100%;
      max-height: 100dvh;
      display: flex;
      flex-direction: column;
      min-height: 0;
      overflow: hidden;
    }
    .app-shell {
      flex: 1;
      display: flex;
      min-height: 0;
      width: 100%;
      overflow: hidden;
    }
    .nav-sidebar {
      flex-shrink: 0;
      width: 240px;
      min-height: 0;
      background: var(--surface);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      transition: width 0.2s ease;
      overflow: hidden;
    }
    .nav-sidebar.collapsed { width: 56px; }
    .nav-sidebar.collapsed .brand-sub,
    .nav-sidebar.collapsed .nav-meta,
    .nav-sidebar.collapsed .nav-label { display: none; }
    .nav-sidebar.collapsed .brand-title {
      font-size: 0.65rem;
      line-height: 1.2;
      text-align: center;
    }
    .nav-top-row {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 0.5rem;
    }
    .nav-sidebar-inner {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      padding: 0.65rem 0.65rem 1rem;
      min-height: 0;
      flex: 1;
      overflow: hidden;
    }
    .nav-toggle {
      align-self: flex-start;
      width: 2.25rem;
      height: 2.25rem;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--accent-soft);
      cursor: pointer;
      font-size: 1rem;
      line-height: 1;
      color: var(--text);
      transition: background 0.15s;
    }
    .nav-toggle:hover { background: #e5e7eb; }
    .nav-sidebar.collapsed .nav-top-row {
      flex-direction: column;
      align-items: center;
      gap: 0.35rem;
    }
    .nav-sidebar.collapsed .nav-toggle { align-self: center; }
    .nav-brand-wrap .brand {
      display: flex;
      flex-direction: column;
      gap: 0.15rem;
    }
    .nav-logo-mark {
      line-height: 0;
      margin-bottom: 0.2rem;
    }
    .nav-logo-svg {
      display: block;
      border-radius: 8px;
      box-shadow: var(--shadow);
    }
    .nav-sidebar.collapsed .nav-logo-mark {
      margin-bottom: 0.25rem;
      align-self: center;
    }
    .brand-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.02em; }
    .brand-sub { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
    /* 对话栏右上角：界面语言（下拉，选项：国旗 - English 名） */
    .locale-fixed {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 0.2rem;
      max-width: min(100%, 18rem);
    }
    .locale-fixed-label {
      display: block;
      width: 100%;
      max-width: 19rem;
      font-size: 0.875rem;
      font-weight: 600;
      letter-spacing: 0.03em;
      color: var(--accent);
      text-align: right;
      line-height: 1.35;
      cursor: default;
    }
    .locale-fixed-select {
      min-width: 0;
      width: 100%;
      max-width: 19rem;
      padding: 0.45rem 1.75rem 0.45rem 0.55rem;
      font-size: 0.8125rem;
      line-height: 1.35;
      color: var(--text);
      background-color: rgba(255, 255, 255, 0.92);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: var(--shadow);
      cursor: pointer;
      outline: none;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 0.6rem center;
    }
    .locale-fixed-select:hover,
    .locale-fixed-select:focus {
      border-color: rgba(0, 0, 0, 0.18);
    }
    .locale-fixed-select:focus {
      box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.12);
    }
    .nav-section {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      padding-top: 0.25rem;
      border-top: 1px solid var(--border);
    }
    .nav-label {
      font-size: 0.65rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--muted);
    }
    .nav-meta {
      font-size: 0.7rem;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #sid {
      font-size: 0.7rem;
      color: var(--muted);
      max-width: 100%;
      line-height: 1.35;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-all;
      user-select: all;
    }
    label.trace {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      font-size: 0.8rem;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
    }
    .nav-item-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 1.05rem;
      margin-right: 0.25rem;
      font-size: 0.85rem;
      line-height: 1;
      vertical-align: middle;
    }
    .nav-item-text {
      display: inline;
    }
    .nav-sidebar.collapsed .nav-item-text {
      display: none;
    }
    .nav-sidebar.collapsed .btn-ghost.w-full {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0.42rem 0.5rem;
    }
    .nav-sidebar.collapsed .btn-ghost.w-full .nav-item-icon {
      margin-right: 0;
      width: auto;
      font-size: 0.95rem;
    }
    .nav-sidebar.collapsed label.trace {
      justify-content: center;
      width: 100%;
      padding: 0.42rem 0.5rem;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: var(--accent-soft);
    }
    .nav-sidebar.collapsed label.trace input {
      display: none;
    }
    .nav-sidebar.collapsed label.trace .nav-item-icon {
      margin-right: 0;
      width: auto;
      font-size: 0.95rem;
    }
    .workspace {
      flex: 1;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      background: var(--bg);
      overflow: hidden;
      transition: padding-right 0.22s ease;
    }
    /* 文件栏打开时不再压缩对话栏宽度，改为覆盖显示 */
    .chat-header {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding: 0.65rem 1.25rem;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
    }
    .chat-header-actions {
      display: inline-flex;
      align-items: center;
      justify-content: flex-end;
      gap: 0.65rem;
      min-width: 0;
      margin-left: auto;
    }
    .btn-session-files {
      display: inline-flex;
      align-items: center;
      gap: 0.45rem;
      max-width: min(100%, 18rem);
    }
    /* [hidden] 须覆盖 .btn-session-files 的 display，否则无文件时仍占位可见 */
    #btnSessionFiles[hidden] {
      display: none !important;
    }
    .btn-session-files .btn-session-files-text {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .file-count-badge {
      flex-shrink: 0;
      min-width: 1.35rem;
      padding: 0.12rem 0.45rem;
      font-size: 0.72rem;
      font-weight: 600;
      line-height: 1.2;
      border-radius: 999px;
      background: var(--accent);
      color: #fff;
    }
    .file-count-badge.is-zero {
      background: var(--accent-soft);
      color: var(--muted);
      font-weight: 500;
    }
    .region-label {
      font-size: 0.65rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
      margin: 0 0 0.35rem 0;
    }
    .nav-sidebar.collapsed .region-label { display: none; }
    .conversation-title {
      font-size: 1rem;
      font-weight: 600;
      letter-spacing: -0.02em;
      margin: 0;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1;
    }
    .conversation-title:empty {
      display: none;
    }
    .chat-header:has(.conversation-title:empty):has(#btnSessionFiles[hidden]):not(:has(#localeFixedWrap)) {
      padding: 0;
      min-height: 0;
      border-bottom: none;
    }
    /* 右侧文件栏：三栏布局中的第 3 栏，可折叠/展开 */
    .files-backdrop {
      width: 0;
      min-width: 0;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      overflow: hidden;
      transition: width 0.22s ease, opacity 0.2s ease, visibility 0.2s ease;
      border-left: 0 solid var(--border);
      background: var(--surface);
    }
    .files-backdrop.open {
      width: min(22rem, 42vw);
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      border-left-width: 1px;
    }
    .files-panel {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
    }
    .files-panel-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      padding: 0.85rem 1rem;
      border-bottom: 1px solid var(--border);
      font-weight: 600;
      font-size: 0.95rem;
    }
    .files-panel-body {
      flex: 1;
      overflow-y: auto;
      padding: 0.75rem 1rem 1rem;
    }
    .files-panel-foot {
      padding: 0.75rem 1rem 1rem;
      border-top: 1px solid var(--border);
    }
    .files-empty {
      font-size: 0.875rem;
      color: var(--muted);
      line-height: 1.5;
      margin: 0;
    }
    .files-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }
    .files-list li {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 0.5rem;
      padding: 0.5rem 0.65rem;
      background: var(--bg);
      border-radius: 10px;
      font-size: 0.8125rem;
      border: 1px solid var(--border);
    }
    .files-list .fname {
      word-break: break-all;
      color: var(--text);
    }
    .files-list .fmeta { flex-shrink: 0; color: var(--muted); font-size: 0.75rem; }
    .file-actions {
      display: flex;
      flex-shrink: 0;
      align-items: center;
      gap: 0.35rem;
    }
    .btn-file-download {
      flex-shrink: 0;
      border: none;
      background: transparent;
      color: var(--accent);
      cursor: pointer;
      font-size: 0.75rem;
      padding: 0.15rem 0.35rem;
      font-weight: 500;
    }
    .btn-file-download:hover { text-decoration: underline; }
    .btn-file-remove {
      flex-shrink: 0;
      border: none;
      background: transparent;
      color: #b91c1c;
      cursor: pointer;
      font-size: 0.75rem;
      padding: 0.15rem 0.25rem;
    }
    .btn-file-remove:hover { text-decoration: underline; }
    .btn-ghost {
      padding: 0.4rem 0.85rem;
      font-size: 0.8125rem;
      font-weight: 500;
      color: var(--text);
      background: var(--accent-soft);
      border: 1px solid var(--border);
      border-radius: 999px;
      cursor: pointer;
      transition: background 0.15s;
    }
    .btn-ghost:hover { background: #e5e7eb; }
    .btn-ghost.w-full { width: 100%; }
    .btn-ghost.btn-icon { padding: 0.35rem 0.65rem; }
    /* 拉满对话栏宽度，滚动条贴在「工作区」右缘；提示与输入仍用 max-width 居中 */
    .main {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
      width: 100%;
      max-width: none;
      margin: 0;
      padding: 0;
      overflow: hidden;
    }
    /* 尚无消息时：输入框在对话栏内垂直居中 */
    .main:has(#chat:empty) {
      justify-content: center;
    }
    .main:has(#chat:empty) #chat {
      flex: 0 0 auto;
      min-height: 0;
      overflow: hidden;
      padding: 0;
      scrollbar-gutter: auto;
    }
    .main:has(#chat:empty) .composer-wrap {
      background: transparent;
      padding-top: 0;
    }
    /* 尚无消息时：输入框上方的 LOGO（有消息后隐藏，避免与顶栏重复） */
    .composer-logo {
      display: none;
      flex-direction: column;
      align-items: center;
      text-align: center;
      gap: 0.35rem;
      margin-bottom: 0.85rem;
      padding: 0 1rem;
      max-width: var(--col-max);
      margin-left: auto;
      margin-right: auto;
    }
    .main:has(#chat:empty) .composer-logo {
      display: flex;
    }
    .composer-logo-mark {
      line-height: 0;
    }
    .composer-logo-svg {
      display: block;
      border-radius: 14px;
      box-shadow: var(--shadow);
    }
    #chat {
      flex: 1;
      min-height: 0;
      width: 100%;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 1rem 0 1.25rem;
      scroll-behavior: smooth;
      -webkit-overflow-scrolling: touch;
      scrollbar-gutter: stable;
    }
    .turn { margin-bottom: var(--turn-gap); max-width: var(--col-max); margin-left: auto; margin-right: auto; }
    .turn.user { display: flex; flex-direction: column; align-items: flex-end; }
    .turn.bot { display: flex; flex-direction: column; align-items: stretch; }
    .turn .label {
      font-size: 0.6875rem;
      color: var(--muted);
      margin-bottom: 0.35rem;
      letter-spacing: 0.02em;
    }
    .turn.user .label { text-align: right; padding-right: 0.25rem; }
    .bubble {
      white-space: pre-wrap;
      word-break: break-word;
      padding: var(--bubble-padding-y) var(--bubble-padding-x);
      border-radius: var(--radius-lg);
      font-size: 0.9375rem;
      line-height: var(--bubble-line-height);
      max-width: 100%;
      box-shadow: var(--shadow);
    }
    .user .bubble {
      background: var(--user-bubble);
      border: none;
      max-width: min(92%, 34rem);
    }
    .bot .bubble {
      background: transparent;
      border: none;
      box-shadow: none;
    }
    .bot .bubble.reply-md {
      white-space: normal;
    }
    .bot .bubble.reply-md h1,
    .bot .bubble.reply-md h2,
    .bot .bubble.reply-md h3 {
      margin: 0.55rem 0 0.4rem;
      font-size: 1.05rem;
      line-height: var(--md-heading-line-height);
    }
    .bot .bubble.reply-md h1 { font-size: 1.15rem; }
    .bot .bubble.reply-md h2 { font-size: 1.1rem; }
    .bot .bubble.reply-md p { margin: var(--md-p-margin-y) 0; }
    .bot .bubble.reply-md p:first-child { margin-top: 0; }
    .bot .bubble.reply-md p:last-child { margin-bottom: 0; }
    .bot .bubble.reply-md ul,
    .bot .bubble.reply-md ol {
      margin: var(--md-p-margin-y) 0;
      padding-left: 1.35rem;
    }
    .bot .bubble.reply-md li { margin: var(--md-li-margin-y) 0; }
    .bot .bubble.reply-md pre,
    .bot .bubble.reply-md code {
      font-family: ui-monospace, SFMono-Regular, monospace;
      font-size: 0.88em;
    }
    .bot .bubble.reply-md pre {
      margin: 0.45rem 0;
      padding: 0.5rem 0.65rem;
      background: var(--bg);
      border-radius: 10px;
      overflow-x: auto;
      white-space: pre-wrap;
      word-break: break-word;
    }
    .bot .bubble.reply-md code { background: var(--bg); padding: 0.08rem 0.28rem; border-radius: 6px; }
    .bot .bubble.reply-md pre code { background: transparent; padding: 0; }
    .bot .bubble.reply-md blockquote {
      margin: 0.4rem 0;
      padding-left: 0.65rem;
      border-left: 3px solid var(--border);
      color: #4b5563;
    }
    .bot .bubble.reply-md table {
      border-collapse: collapse;
      width: 100%;
      font-size: 0.9em;
      margin: 0.45rem 0;
    }
    .bot .bubble.reply-md th,
    .bot .bubble.reply-md td {
      border: 1px solid var(--border);
      padding: 0.35rem 0.5rem;
      text-align: left;
    }
    .bot .bubble.reply-md th { background: var(--bg); }
    .trace-mini { margin-top: 0.5rem; font-size: 0.78rem; color: var(--muted); }
    .trace-mini pre {
      margin: 0.35rem 0 0;
      white-space: pre-wrap;
      word-break: break-word;
      background: var(--bg);
      padding: 0.5rem 0.65rem;
      border-radius: 10px;
      border: 1px solid var(--border);
      max-height: 14rem;
      overflow: auto;
    }
    .composer-wrap {
      flex-shrink: 0;
      padding: 0.75rem 1rem 1.25rem;
      background: linear-gradient(180deg, transparent 0%, var(--bg) 12%);
      min-height: 0;
    }
    .composer-inner {
      max-width: var(--col-max);
      margin: 0 auto;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-xl);
      box-shadow: var(--shadow-composer);
      padding: 0.65rem 0.75rem 0.75rem;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }
    #q {
      width: 100%;
      min-height: 3.25rem;
      max-height: 12rem;
      padding: 0.5rem 0.6rem;
      font: inherit;
      font-size: 0.9375rem;
      line-height: 1.5;
      border: none;
      resize: vertical;
      background: transparent;
      outline: none;
    }
    #q::placeholder { color: #9ca3af; }
    .composer-row {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 0.5rem;
      padding-top: 0.15rem;
      border-top: 1px solid var(--border);
    }
    .composer-hint { font-size: 0.7rem; color: var(--muted); margin-right: auto; }
    #go {
      padding: 0.45rem 1.15rem;
      font-size: 0.875rem;
      font-weight: 600;
      color: #fff;
      background: var(--accent);
      border: none;
      border-radius: 999px;
      cursor: pointer;
      transition: opacity 0.15s;
    }
    #go:hover:not(:disabled) { opacity: 0.92; }
    #go:disabled { opacity: 0.45; cursor: not-allowed; }
    .err { color: #b91c1c; }
    .confirm-panel {
      margin-top: 0.65rem;
      padding: 0.85rem 1rem;
      background: var(--user-bubble);
      border: none;
      border-radius: var(--radius-lg);
      font-size: 0.875rem;
      box-shadow: none;
    }
    .confirm-title { font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
    .confirm-hint {
      font-size: 0.8125rem;
      color: #4b5563;
      margin: 0 0 0.55rem 0;
      line-height: 1.5;
    }
    .confirm-table-wrap { overflow-x: auto; margin-top: 0.35rem; }
    .confirm-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.8125rem;
      background: transparent;
    }
    .confirm-table th,
    .confirm-table td {
      border: 1px solid var(--border);
      padding: 0.4rem 0.45rem;
      vertical-align: middle;
    }
    .confirm-table thead th {
      background: var(--bg);
      font-weight: 600;
      text-align: left;
    }
    .confirm-table .td-val-cell {
      min-width: 4.5rem;
      vertical-align: top;
      padding: 0.3rem 0.35rem;
    }
    /* 产品需求列表：各确认列区分底色（需客户核对/填写的值区） */
    .confirm-table .td-col-standard { background: #fff7ed; }
    .confirm-table .td-col-spec { background: #ecfeff; }
    .confirm-table .td-col-grade { background: #eff6ff; }
    .confirm-table .td-col-surface { background: #f5f3ff; }
    .confirm-table .td-col-qty { background: #fefce8; }
    .confirm-field-input,
    .confirm-field-select {
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      padding: 0.4rem 0.45rem;
      font: inherit;
      font-size: inherit;
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.92);
    }
    .confirm-field-select {
      cursor: pointer;
      appearance: auto;
    }
    .confirm-field-input:focus,
    .confirm-field-select:focus {
      outline: none;
      border-color: #64748b;
      box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.12);
    }
    .confirm-all { margin-top: 0.65rem; }
    .btn-all {
      padding: 0.45rem 1.1rem;
      font-weight: 600;
      font-size: 0.875rem;
      color: #fff;
      background: var(--accent);
      border: none;
      border-radius: 999px;
      cursor: pointer;
    }
    .btn-all:hover { opacity: 0.92; }
    .turn-foot { margin-top: 0.45rem; font-size: 0.8125rem; }
    .btn-pdf {
      padding: 0.35rem 0.65rem;
      font-size: 0.8125rem;
      cursor: pointer;
      background: var(--accent-soft);
      border: 1px solid var(--border);
      border-radius: 999px;
      color: var(--text);
    }
    .btn-pdf:hover { background: #e5e7eb; }
    .confirm-table .td-product {
      word-break: break-word;
      min-width: 6rem;
      max-width: 14rem;
      vertical-align: top;
      background: var(--bg);
      color: #374151;
      font-weight: 500;
    }
