.files-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.mobile-records {
  display: none;
}
.file-help-intro {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.file-help-detail,
.memory-help {
  color: var(--muted);
  font-size: 12px;
}
.file-help-detail summary,
.memory-help summary {
  width: fit-content;
  padding: 5px 0;
  color: var(--a1);
  cursor: pointer;
  font-weight: 600;
}
.file-help-detail .file-help,
.memory-help .real-form-note {
  margin: 5px 0 0;
}
.file-search-results {
  padding: 18px;
}
.file-search-results h3 {
  font-size: 15px;
  margin-bottom: 14px;
}
.file-search-hit + .file-search-hit {
  border-top: 1px solid var(--stroke);
  margin-top: 14px;
  padding-top: 14px;
}
#attachRow {
  max-height: min(160px, 24dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.input-wrap textarea:focus {
  outline: none;
  box-shadow: none;
}
.files-tabs button[aria-selected="true"] {
  color: var(--a1);
  background: var(--purple-bg);
  border-color: var(--a1);
}
.file-name {
  max-width: 460px;
  min-width: 160px;
  white-space: normal !important;
  overflow-wrap: anywhere;
}
.file-name small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.6;
}
.file-status {
  white-space: nowrap;
}
.file-media-player {
  width: 100%;
  min-width: 0;
  margin: 14px 0;
}
.file-media-player video {
  display: block;
  width: 100%;
  max-height: 55dvh;
  background: #111827;
  border-radius: 10px;
}
.file-media-player audio {
  width: 100%;
  display: block;
}
.file-media-player.compact {
  width: min(320px, 100%);
  margin: 10px 0 0;
}
.file-media-player.compact video {
  max-height: 180px;
}
.file-status[data-status="failed"] {
  color: var(--red);
}
.file-status[data-status="ready"] {
  color: var(--green);
}
.file-help,
.upload-progress {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 16px;
}
.upload-progress:empty {
  display: none;
}
.file-text-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  max-height: 42vh;
  max-height: 42dvh;
  overflow: auto;
  padding: 16px;
  background: var(--purple-bg);
  border-radius: 12px;
  margin-top: 12px;
  font-size: 13px;
}
.file-detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.file-detail-section {
  margin: 14px 0;
}
.file-detail-section h4 {
  font-size: 13px;
  margin-bottom: 8px;
}
.file-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.file-detail-actions a {
  display: inline-flex;
  color: inherit;
  text-decoration: none;
}
.modal.document-preview-modal {
  display: flex;
  flex-direction: column;
  width: 680px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
}
.document-preview-modal .modal-title {
  flex: 0 0 auto;
  gap: 12px;
  margin-bottom: 14px;
}
.document-preview-modal #modalTitle {
  min-width: 0;
  max-height: 4.5em;
  overflow: auto;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.document-preview-modal #modalClose {
  flex: 0 0 auto;
}
.document-preview-modal .modal-body,
.document-preview {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.document-preview {
  gap: 14px;
}
.document-preview-toolbar {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 12px;
}
.document-preview-toolbar:empty {
  display: none;
}
.document-preview-toolbar .file-detail-meta,
.document-preview-toolbar .file-detail-actions {
  margin: 0;
}
.document-preview-content {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  max-height: 52vh;
  max-height: min(52dvh, 560px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 16px;
  border-radius: 12px;
  background: var(--purple-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.document-preview-content pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}
.document-preview-content .file-detail-section:first-child {
  margin-top: 0;
}
.document-preview-content .file-detail-section + .file-detail-section {
  border-top: 1px solid var(--stroke);
  padding-top: 14px;
}
.document-preview-content .file-detail-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
}
.document-preview-content .real-form-note {
  margin: 0 0 12px;
}
.document-preview-modal #modalStatus {
  flex: 0 0 auto;
  max-height: 15vh;
  overflow: auto;
}
.document-preview-modal #modalStatus:empty,
.document-preview-modal .modal-foot {
  display: none;
}
.modal.document-preview-modal:has(.has-document-layout) { width:min(1120px,96vw); }
.has-document-layout .document-preview-content { max-height:none; height:min(68vh,820px); height:min(68dvh,820px); padding:0; background:var(--surface,#fff); border:1px solid var(--stroke); }
.document-preview-tabs { display:flex; gap:8px; }
.document-preview-tabs .active { background:var(--purple-bg); color:var(--accent,#7e6bef); border-color:currentColor; }
.document-preview-notice { max-height:12vh; overflow:auto; }
.document-preview-notice p { margin:0; }
.has-image-preview .document-preview-notice { max-height:none; overflow:visible; }
.document-image-preview { margin:0; text-align:center; }
.document-image-preview img { display:block; max-width:100%; max-height:40vh; object-fit:contain; margin:0 auto; }
.document-image-preview figcaption { margin-top:10px; font-size:12px; color:var(--muted); }
.document-preview-content [data-preview-layout] { height:100%; display:flex; flex-direction:column; }
.document-preview-content [hidden] { display:none!important; }
[data-layout-status] { flex:none; padding:10px 14px; margin:0!important; background:var(--purple-bg); }
[data-layout-output] { flex:1; min-height:0; display:flex; flex-direction:column; }
.document-layout-frame { width:100%; height:100%; min-height:300px; flex:1; border:0; background:white; }
.document-layout-controls { padding:7px 12px; display:flex; justify-content:flex-end; border-bottom:1px solid var(--stroke); }
[data-preview-text] { padding:16px; }
[data-layout-output] canvas { max-width:100%; height:auto; display:block; margin:0 auto; }
[data-layout-output]:has(canvas) { overflow:auto; display:block; }
@media (max-width: 600px) {
  .modal.document-preview-modal {
    padding: 16px;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .document-preview-content {
    padding: 12px;
  }
}
.file-pagination {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  font-size: 12px;
  color: var(--muted);
}
.file-attachment {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--purple-bg);
  padding: 6px 9px;
  font-size: 12px;
  color: var(--text);
}
.file-attachment > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.file-attachment button {
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0 3px;
}
.file-attachment button:disabled {
  opacity: 0.4;
}
.file-selection-note {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.file-inline-status {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
.upload-queue-item { position: relative; display: flex; flex-wrap: wrap; width: 94px; min-height: 88px; padding: 6px; gap: 4px; }
.upload-queue-item > img { width: 80px; height: 64px; object-fit: contain; border-radius: 5px; }
.image-upload-progress { display: block; width: 100%; height: 4px; border: 0; border-radius: 4px; overflow: hidden; accent-color: var(--a1); background: var(--stroke); }
.image-upload-progress::-webkit-progress-bar { background: var(--stroke); border-radius: 4px; }
.image-upload-progress::-webkit-progress-value { background: var(--a1); border-radius: 4px; transition: width .12s linear; }
.image-upload-progress::-moz-progress-bar { background: var(--a1); }
.image-upload-progress:not([value]) { background: linear-gradient(90deg,var(--stroke) 0%,var(--a1) 50%,var(--stroke) 100%); background-size: 200% 100%; animation: upload-processing 1.4s linear infinite; }
.upload-queue-item .upload-error-icon { color: var(--danger,#b42318); }
.upload-queue-item button { min-width: 24px; min-height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.upload-edit-icon { width: 32px; height: 32px; align-self: center; display: inline-flex; align-items: center; justify-content: center; padding: 6px; }
#attachRow .image-attachment { position: relative; }
#attachRow .image-attachment .attachment-preview { width: 80px; }
.file-attachment.image-attachment > [data-remove-file],
.file-attachment.upload-queue-item:has(> img) > [data-upload-remove] {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  line-height: 1;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .file-attachment.image-attachment > [data-remove-file],
  .file-attachment.upload-queue-item:has(> img) > [data-upload-remove] {
    opacity: 0;
    pointer-events: none;
  }
  .file-attachment.image-attachment:is(:hover, :focus-within) > [data-remove-file],
  .file-attachment.upload-queue-item:has(> img):is(:hover, :focus-within) > [data-upload-remove] {
    opacity: 1;
    pointer-events: auto;
  }
}
#fileUploadQueue { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
@keyframes upload-processing { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .image-upload-progress:not([value]) { animation: none; } }
.file-drop-active {
  outline: 2px dashed var(--a1);
  outline-offset: -4px;
}
.message-files,
.message-sources {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
  max-width: 100%;
}
.message-files button,
.message-sources button {
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
}
.source-detail summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding-top: 8px;
}
.source-detail {
  max-width: 100%;
}
.message-source-snippet {
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
  line-height: 1.7;
}
.msg-actions .memory-save {
  width: auto;
  padding: 3px 7px;
  font-size: 11px;
  color: var(--muted);
}
.memory-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  gap: 16px;
  margin-bottom: 16px;
}
.memory-setting h3 {
  font-size: 15px;
  margin-bottom: 7px;
}
.memory-setting p {
  margin: 0;
}
.memory-setting button {
  flex: none;
}
.memory-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: none;
}
.memory-controls .btn {
  font-size: 12px;
}
.memory-excerpt {
  margin: 7px 0 0;
  white-space: pre-wrap;
  line-height: 1.7;
  color: var(--muted);
  font-size: 12px;
}
.input-wrap textarea {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.7;
}
.form-row > select {
  width: 100%;
  padding: 11px;
}
.ctx-summary {
  white-space: pre-wrap;
}
.ctx-sec > .btn {
  width: 100%;
  margin-top: 10px;
  font-size: 12px;
}
.ocr-progress {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  white-space: pre-wrap;
}
@media (max-width: 600px) {
  .desktop-records {
    display: none;
  }
  .mobile-records {
    display: grid;
    gap: 10px;
  }
  .mobile-record-card {
    min-width: 0;
    padding: 14px;
  }
  .mobile-record-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }
  .mobile-record-head h4,
  .mobile-record-title {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
  }
  .mobile-record-title {
    padding: 0;
    text-align: left;
    color: var(--a1);
    cursor: pointer;
  }
  .mobile-record-head .badge,
  .mobile-record-head .file-status {
    flex: none;
  }
  .mobile-record-meta {
    margin: 8px 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .mobile-record-card > small {
    display: block;
    margin: 6px 0;
    line-height: 1.5;
  }
  .mobile-record-card > .btn {
    margin-top: 5px;
  }
  .mobile-record-card .memory-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    margin: 8px 0;
    font-size: 13px;
  }
  .mobile-record-actions summary {
    width: fit-content;
    padding: 7px 0;
    color: var(--a1);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
  }
  .mobile-record-actions > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
  }
  .memory-setting {
    align-items: flex-start;
    flex-direction: column;
  }
  .file-detail-actions > * {
    flex: 1;
    justify-content: center;
  }
  .file-attachment > span {
    max-width: 150px;
  }
  .file-name {
    min-width: 135px;
    max-width: 230px;
  }
  .files-tabs {
    gap: 6px;
  }
  .file-help {
    font-size: 13px;
  }
  .memory-setting .real-form-note {
    font-size: 13px;
    line-height: 1.6;
  }
}
.vision-assist {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 4px 0 10px;
  font-size: 14px;
  line-height: 1.5;
}
.vision-assist[hidden] {
  display: none;
}
.vision-assist label {
  color: var(--text);
}
.vision-assist .sel {
  max-width: 100%;
  min-height: 34px;
  font-size: 14px;
}
.vision-assist > span {
  flex-basis: 100%;
  color: var(--muted);
}
.vision-route {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  overflow-wrap: anywhere;
  margin-bottom: 6px;
}
.modal.document-preview-modal:has(.spreadsheet-preview) { width: min(1200px, 96vw); }
.document-preview-content:has(.spreadsheet-preview) { background: var(--surface, #fff); padding: 0; max-height: 65vh; }
.document-preview-content:has(.spreadsheet-preview) > .real-form-note { padding: 10px 14px; }
.spreadsheet-tabs { display: flex; gap: 6px; padding: 10px 12px; overflow-x: auto; border-bottom: 1px solid var(--stroke); }
.spreadsheet-tabs .active { color: var(--a1); background: var(--purple-bg); }
.spreadsheet-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); }
.spreadsheet-controls > div { display: flex; align-items: center; gap: 8px; }
.spreadsheet-grid { overflow: auto; max-height: 48vh; border-block: 1px solid var(--stroke); }
.spreadsheet-grid table { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; margin: 0; }
.spreadsheet-grid th, .spreadsheet-grid td { min-width: 100px; padding: 7px 8px; border-right: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke); white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: top; font-size: 13px; line-height: 1.5; }
.spreadsheet-grid th { color: var(--muted); background: var(--panel, #f7f8fc); text-align: center; font-weight: 500; }
.spreadsheet-grid thead th { position: sticky; top: 0; z-index: 3; }
.spreadsheet-grid tr > th:first-child { min-width: 44px; width: 44px; position: sticky; left: 0; z-index: 2; }
.spreadsheet-grid thead th:first-child { z-index: 4; }
.spreadsheet-grid .spreadsheet-heading { font-weight: 600; background: var(--purple-bg); position: sticky; top: 34px; z-index: 2; }
.spreadsheet-grid tbody tr:first-child:has(.spreadsheet-heading) > th { top: 34px; z-index: 3; }
.spreadsheet-grid td img { display: block; width: 100%; max-width: 260px; max-height: 160px; object-fit: contain; }
.spreadsheet-image-label { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.document-embedded-images { padding: 12px; }
.document-embedded-images > div { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.document-embedded-images figure { margin: 0; max-width: 280px; }
.document-embedded-images img { display: block; max-width: 100%; max-height: 220px; object-fit: contain; }
.document-embedded-images figcaption { color: var(--muted); font-size: 12px; margin-top: 5px; overflow-wrap: anywhere; }
@media (max-width: 600px) { .modal.document-preview-modal:has(.spreadsheet-preview) { width: 100%; } .spreadsheet-controls .btn { padding: 5px 8px; } .spreadsheet-grid { max-height: 42vh; } }
.video-frame-ledger{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin:16px 0}.video-frame-ledger figure{margin:0;min-width:0}.video-frame-ledger img{width:100%;height:140px;object-fit:contain;background:var(--bg);border:1px solid var(--line);border-radius:8px}.video-frame-ledger figcaption{font-size:12px;color:var(--muted);margin-top:6px;overflow-wrap:anywhere}
