.attachment-spinner { width: 14px; height: 14px; flex-shrink: 0; border: 2px solid #d9e6df; border-top-color: #198754; border-radius: 50%; animation: attachment-spin 1s linear infinite; }
@keyframes attachment-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .attachment-spinner { animation: none; } }
.attachment-upload-chip { flex-wrap: wrap; max-width: 100%; padding: 6px 8px; gap: 6px; }
.attachment-inline-status { font-size: 12px; color: #61756a; }
.attachment-upload-error { border-color: #dfb5b5; }
.attachment-inline-error { flex-basis: 100%; color: #ad3434; overflow-wrap: anywhere; }
.attachment-upload-chip .attachment-remove { opacity: 1; }
.composer-resize { height: 12px; cursor: ns-resize; touch-action: none; display: flex; align-items: center; justify-content: center; }
.composer-resize::after { content: ''; width: 44px; height: 3px; background: #c9d1cd; border-radius: 3px; }
.composer-resize:focus-visible { outline: 2px solid #82a9ec; border-radius: 4px; }
.file-status-detail {
  overflow-wrap: anywhere;
  display: block;
  max-width: 260px;
  color: #717784;
  margin-top: 5px;
  line-height: 1.5;
}
.attachment-summary-chip { flex-wrap: wrap; padding: 4px 6px; }
.attachment-summary-note { flex-basis: 100%; color: #61756a; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.attachment-selected-list { display: flex; flex-wrap: wrap; gap: 4px 8px; width: 100%; max-height: 160px; overflow-y: auto; }
.attachment-selection-toggle { max-width: 100%; text-align: left; }
.attachment-selection-toggle span { white-space: normal; overflow-wrap: anywhere; }
.attachment-pagination, .attachment-batch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.attachment-page-summary { flex: 1; min-width: 120px; text-align: center; line-height: 1.6; overflow-wrap: anywhere; }
.attachment-page-summary > span, .attachment-page-summary > small { display: block; }
.attachment-page-summary > small { color: #667085; }
.attachment-page-summary > small > span { display: inline-block; white-space: nowrap; }
.attachment-page-summary > [hidden] { display: none; }
.attachment-pagination > button { flex-shrink: 0; }
.attachment-pagination button[hidden], .attachment-schedule-picker [hidden] { display: none; }
.attachment-targets, .attachment-reference-details, .attachment-conversation-choices { max-height: 260px; overflow-y: auto; }
.attachment-target { display: block; width: 100%; text-align: left; margin-bottom: 5px; white-space: normal; overflow-wrap: anywhere; }
.attachment-schedule-selection { display: flex; flex-wrap: wrap; gap: 6px; }
.attachment-schedule-picker summary { cursor: pointer; padding: 8px 0; }
.attachment-reference-details p, .attachment-selector .reference-option span { overflow-wrap: anywhere; }
.reference-file-detail { display: flex; flex: 1; flex-direction: column; min-width: 0; gap: 4px; }
.reference-file-detail small { font-size: 11px; line-height: 1.5; }
#dialog:has(.attachment-reference-picker) { width: min(640px, calc(100vw - 32px)); height: min(740px, 90dvh); box-sizing: border-box; padding: 0; overflow: hidden; }
#dialog:has(.attachment-reference-picker) > .dialog-head { padding: 20px 24px 10px; margin: 0; }
#dialog:has(.attachment-reference-picker) > #dialogBody { display: flex; min-height: 0; height: calc(100% - 64px); overflow: hidden; }
.attachment-reference-picker { display: flex; flex: 1; min-width: 0; min-height: 0; flex-direction: column; padding: 0 24px; }
.attachment-reference-picker > .muted { margin: 0 0 6px; flex-shrink: 0; }
.attachment-reference-picker > .field { margin: 8px 0 12px; flex-shrink: 0; }
.reference-picker-tabs { display: flex; gap: 20px; flex-shrink: 0; border-bottom: 1px solid var(--border, #e7e7e7); margin-bottom: 12px; }
.reference-picker-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 0; background: transparent; color: var(--muted, #777); }
.reference-picker-tabs button[aria-selected="true"] { color: var(--text, #222); border-bottom-color: currentColor; font-weight: 600; }
.attachment-reference-picker > .attachment-selector { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.attachment-reference-picker .reference-selection-list, .attachment-reference-picker > .attachment-conversation-choices { flex: 1; min-height: 0; max-height: none; overflow-y: auto; border: 1px solid var(--border, #e7e7e7); border-radius: 12px; padding: 6px; margin: 0; }
.attachment-reference-picker .reference-option { align-items: flex-start; }
.attachment-reference-picker .reference-option > input, .attachment-reference-picker .reference-option > img { margin-top: 2px; }
.attachment-reference-picker .attachment-pagination { flex-wrap: nowrap; flex-shrink: 0; margin: 8px 0; gap: 6px; }
.attachment-reference-picker .attachment-page-summary { min-width: 0; font-size: 12px; }
.attachment-reference-picker .attachment-page-summary > small { font-size: 10px; }
.attachment-reference-picker .attachment-page-summary > small:last-child { display: none; }
.reference-picker-footer { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px; padding: 14px 0 18px; margin-top: 8px; border-top: 1px solid var(--border, #e7e7e7); }
.reference-picker-footer > p { margin: 0; font-size: 11px; }
.reference-picker-footer .row-actions { gap: 8px; flex-shrink: 0; }
.attachment-reference-picker [hidden] { display: none; }
@media (max-width: 640px) {
  #dialog:has(.attachment-reference-picker) { width: calc(100vw - 20px); height: min(740px, calc(100dvh - 24px)); max-height: calc(100dvh - 24px); }
  #dialog:has(.attachment-reference-picker) > .dialog-head { padding: 16px 16px 10px; }
  #dialog:has(.attachment-reference-picker) > #dialogBody { height: calc(100% - 60px); }
  .attachment-reference-picker { padding: 0 16px; }
  .attachment-reference-picker .attachment-selector .reference-selection-list { max-height: none; }
  .reference-picker-footer { flex-wrap: wrap; gap: 8px; padding: 10px 0 14px; }
  .reference-picker-footer .row-actions { width: 100%; justify-content: flex-end; }
}
/* 个人附件沿用平台配色和控件风格，列表内展示上传进度。 */
#main:has(> .file-library-page:not([hidden])) > .topbar {
  height: 28px;
  padding-block: 0;
}
.page.file-library-page {
  max-width: 1440px;
  margin: 8px auto 48px;
  padding: 0 40px;
}
.file-library-page > .subtitle {
  margin: 6px 0 20px;
  line-height: 1.6;
}
#fileLibrary [hidden] { display: none !important; }
#fileStorage {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f3f3f3;
}
#fileStorage p { flex-shrink: 0; margin: 0; font-size: 13px; }
#fileStorage strong { color: #141414; font-weight: 600; }
#fileStorage progress { flex: 1; min-width: 0; width: auto; margin: 0; background: #e0e0e0; }
#fileLibrary progress::-webkit-progress-value { border-radius: 8px; }
#fileLibrary progress::-moz-progress-bar { border-radius: 8px; background: #39b67d; }
#fileLibrary .file-controls { display: grid; grid-template-columns: minmax(110px, 140px) minmax(0, 1fr) auto auto; gap: 10px; }
#fileLibrary .file-controls select,
#fileLibrary .file-controls input {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fcfcfc;
  color: inherit;
  font-size: 13px;
}
#fileLibrary .file-controls select { padding: 6px 10px; text-overflow: ellipsis; }
#fileLibrary .file-search { position: relative; min-width: 0; }
#fileLibrary .file-search > .icon { position: absolute; top: 10px; left: 11px; width: 16px; height: 16px; opacity: .45; pointer-events: none; }
#fileLibrary .file-search input { padding: 7px 12px 7px 34px; }
#fileLibrary .file-search input::placeholder { color: #999; }
#fileLibrary .file-controls > button { min-height: 36px; padding: 8px 14px; border-radius: 8px; font-size: 13px; }
#fileLibrary input[type="checkbox"] { accent-color: #141414; }
#fileLibrary .file-drop-hint { margin: 10px 0 0; color: #999; }
.file-drop-tip { margin-top: 14px; padding: 22px 16px; border: 2px dashed #999; border-radius: 12px; background: #f5f5f5; color: #555; text-align: center; font-size: 14px; line-height: 1.6; }
.file-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 402px;
  margin-top: 14px;
  padding: 48px 24px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: center;
  overflow-wrap: anywhere;
}
.file-empty-icon { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 24px; background: #f3f3f3; }
.file-empty-icon > .icon { width: 36px; height: 36px; opacity: .55; }
.file-empty-state h2 { margin: 20px 0 8px; font-size: 16px; line-height: 24px; font-weight: 650; }
.file-empty-state p { margin: 0; color: #777; font-size: 13px; line-height: 22px; }
.file-empty-state > button { min-height: 36px; margin-top: 20px; }
.file-empty-destination { margin-top: 10px; color: #999; font-size: 12px; }
.file-empty-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 28px; margin: 24px 0 0; padding: 0; list-style: none; color: #999; font-size: 12px; }
.file-empty-steps li { display: flex; align-items: center; gap: 6px; }
.file-step-number { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #f3f3f3; color: #777; font-size: 11px; }
#fileBatchActions { padding: 8px 14px; margin: 14px 0 0; border: 1px solid var(--line); border-radius: 10px; background: #f5f5f5; font-size: 13px; }
#fileBatchActions > span { margin-right: auto; color: #777; }
#fileBatchActions > button { font-size: 12px; }
#fileBatchActions > button:not(.primary) { background: transparent; border-color: transparent; color: #777; }
#fileBatchActions > button:not(.primary):hover { background: #eee; }
#fileLibrary > .attachment-pagination { justify-content: flex-end; gap: 12px; margin: 14px 0 0; font-size: 12px; color: #777; }
#fileLibrary > .attachment-pagination .attachment-page-summary > small { color: #777; }
#fileLibrary > .attachment-pagination .attachment-page-summary { flex: none; min-width: 0; }
#fileLibrary > .attachment-pagination .attachment-page-summary > small:last-child { display: none; }
#fileResults { margin-top: 14px; }
#fileResults .table-wrap { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
#fileResults th { padding: 10px 12px; background: #f5f5f5; color: #777; font-weight: 500; }
#fileResults th:first-child { padding-left: 16px; }
#fileResults td { padding: 12px; border-color: #eee; }
#fileResults td:first-child { padding-left: 16px; max-width: none; }
#fileResults tbody:last-child tr:last-child td { border-bottom: 0; }
#fileResults tbody tr:hover { background: #fafafa; }
#fileResults .name-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-name-heading { display: flex; align-items: center; gap: 16px; }
#fileLibrary .file-type-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 8px; font-size: 10px; font-weight: 700; background: #f5f5f5; color: #666; }
#fileLibrary .file-type-icon > .icon { width: 19px; height: 19px; opacity: .65; }
.file-name-detail { min-width: 0; flex: 1; }
#fileResults .file-name-text { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
#fileResults .file-name-detail small { font-size: 12px; color: #999; }
#fileResults .row-actions button,
#fileResults .row-actions a { min-height: 28px; padding: 4px 6px; font-size: 12px; }
#fileResults .row-actions { justify-content: flex-start; gap: 6px; flex-wrap: nowrap; }
#fileResults .row-actions .file-icon-operation { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; padding: 5px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
#fileResults .file-icon-operation .icon { width: 16px; height: 16px; opacity: .5; }
#fileResults .file-icon-operation:hover { background: #eee; border-color: var(--line); }
#fileResults .file-icon-operation:hover .icon { opacity: 1; }
#fileResults .row-actions .file-cite-button { padding: 4px 11px; border: 1px solid #ddd; border-radius: 8px; background: #fcfcfc; color: inherit; line-height: 1.6; }
#fileResults .file-cite-button:hover:not(:disabled) { background: #f1f1f1; }
#fileResults .file-state, #fileResults .file-upload-state { font-size: 12px; line-height: 1.6; }
.file-state-label { display: inline-flex; align-items: center; gap: 6px; }
.file-state > .file-state-label { color: #777; }
.file-state.is-ready > .file-state-label, .file-upload-state.is-ready > .file-state-label { color: #229755; }
.file-state.is-ready > .file-state-label::before, .file-upload-state.is-ready > .file-state-label::before { content: "✓"; }
.file-upload-state { color: #777; }
.file-upload-state.is-error, .file-upload-state.is-error .file-status-detail { color: #ad3434; }
.file-upload-state.is-error .file-state-label { cursor: help; white-space: nowrap; }
.file-upload-state.is-error .file-state-label > .icon { width: 14px; height: 14px; opacity: .6; }
.file-upload-state progress { display: block; height: 5px; width: 100%; margin-top: 5px; }
#fileLibrary .name-cell input[type="checkbox"], #fileLibrary .file-name-heading input { width: 15px; height: 15px; margin: 0; flex-shrink: 0; }
.file-action-menu { position: fixed; z-index: 120; min-width: 150px; max-width: calc(100vw - 16px); padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 4px 20px #0001; }
.file-action-menu > button { display: flex; width: 100%; align-items: center; justify-content: flex-start; gap: 8px; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: #555; font-size: 13px; white-space: nowrap; }
.file-action-menu > button:hover, .file-action-menu > button:focus-visible { background: #f4f4f4; color: #141414; }
.file-action-menu > button.danger { color: #b85454; }
.file-action-menu > button.danger:hover { background: #fff5f5; }
.file-action-menu .icon { width: 16px; height: 16px; opacity: .6; }
.file-menu-separator { height: 1px; margin: 4px 6px; background: var(--line); }
@media (min-width: 761px) {
  #fileResults table { table-layout: fixed; width: 100%; min-width: 850px; }
  #fileResults th:nth-child(2) { width: 96px; }
  #fileResults th:nth-child(3) { width: 132px; }
  #fileResults th:nth-child(4) { width: 78px; }
  #fileResults th:nth-child(5) { width: 126px; }
  #fileResults th:nth-child(6) { width: 178px; }
  #fileResults td { vertical-align: middle; overflow-wrap: anywhere; }
  #fileResults .file-upload-row .row-actions { flex-wrap: wrap; }
  #fileResults .row-actions button, #fileResults .row-actions a { white-space: nowrap; }
}
@media (max-width: 640px) {
  .attachment-selected-list { max-height: 120px; }
  .attachment-selector .reference-selection-list { max-height: 220px; }
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  max-width: 280px;
  gap: 2px;
  margin-bottom: 8px;
  padding: 0 3px;
  border-radius: 8px;
  background: #f5f5f5;
}
.chips .attachment-chip button {
  margin: 0;
  background: transparent;
}
.chips .attachment-chip .attachment-name {
  min-width: 0;
  text-align: left;
}
.attachment-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chips .attachment-chip .attachment-remove {
  flex: none;
  padding: 5px;
  width: 25px;
  height: 28px;
  opacity: 1;
}
.attachment-chip:hover .attachment-remove,
.attachment-chip:focus-within .attachment-remove {
  opacity: 1;
}
.attachment-uploads {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 120;
  width: min(380px, calc(100vw - 32px));
  max-height: 50vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid #dce1e6;
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 4px 20px #0002;
}
.attachment-uploads[hidden] {
  display: none;
}
.attachment-upload-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.attachment-upload-row {
  border-top: 1px solid #eee;
  padding-top: 10px;
}
.attachment-upload-name {
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attachment-upload-status {
  font-size: 12px;
  line-height: 1.6;
  color: #606b79;
  overflow-wrap: anywhere;
  margin-top: 5px;
}
.attachment-upload-row progress {
  width: 100%;
  height: 6px;
}
@media (hover: none) {
  .chips .attachment-chip .attachment-remove {
    opacity: 1;
  }
}
@media (max-width: 640px) {
  .attachment-uploads {
    right: 16px;
    bottom: 16px;
    max-height: 35vh;
  }
}
@media (max-width: 760px) {
  #main:has(> .file-library-page:not([hidden])) > .topbar { height: 48px; }
  .page.file-library-page { margin: 8px auto 32px; padding: 0 16px; }
  #fileStorage { flex-direction: column; align-items: stretch; gap: 10px; }
  #fileStorage progress { flex: none; width: 100%; }
  #fileLibrary .file-controls { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  #fileLibrary .file-search { grid-column: 1 / -1; grid-row: 2; }
  .file-empty-state { min-height: 380px; padding: 32px 16px; }
  .file-empty-icon { width: 72px; height: 72px; border-radius: 20px; }
  .file-empty-steps { gap: 12px; }
  #fileResults .table-wrap {
    margin: 0;
    overflow: visible;
    border: 0;
    background: transparent;
  }
  #fileResults table,
  #fileResults tbody {
    display: block;
  }
  #fileResults thead {
    display: none;
  }
  #fileResults tr {
    display: block;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
  }
  #fileResults td {
    display: grid;
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 8px;
    padding: 5px 0;
    border: 0;
    max-width: none;
  }
  #fileResults td::before {
    content: attr(data-label);
    color: #999;
  }
  #fileResults td:first-child,
  #fileResults td:last-child {
    display: block;
  }
  #fileResults td:first-child::before,
  #fileResults td:last-child::before {
    display: none;
  }
  #fileResults .name-cell {
    font-weight: 500;
    margin-bottom: 6px;
  }
  #fileResults .row-actions {
    justify-content: flex-start;
    gap: 6px;
    margin-top: 6px;
  }
  #fileResults .row-actions button,
  #fileResults .row-actions a {
    min-height: 32px;
  }
}
.composer-feedback,
.file-drop-hint {
  margin: 4px 0 10px;
  color: var(--muted, #666);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.composer-feedback-blocked {
  color: #a33b28;
}
.composer-feedback {
  padding: 0 6px;
}
.composer-upload-hint {
  min-width: 0;
  color: var(--muted, #666);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.composer-left > .round-button {
  flex-shrink: 0;
}
.file-drop-overlay {
  position: fixed;
  inset: 16px;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 2px dashed var(--accent, #5576dd);
  border-radius: 20px;
  background: rgba(247, 249, 255, 0.94);
  pointer-events: none;
  box-sizing: border-box;
  color: #263963;
}
.file-drop-overlay[hidden] {
  display: none;
}
.file-drop-card {
  max-width: 480px;
  text-align: center;
  overflow-wrap: anywhere;
}
.file-drop-card > .icon {
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
}
.file-drop-card strong {
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.4;
}
.file-drop-card p {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.7;
}
.file-drop-blocked {
  border-color: #a33b28;
  color: #833320;
  background: rgba(255, 249, 246, 0.96);
}
