/* 채팅 첨부 (chat-attach.js). 히든아이 · Stage9 의 각 사이트 색상 변수를 그대로 따릅니다 (없으면 기본값).
   같은 파일이 히든아이 static/css, Stage9 static/css, Stage9 legacy_ko/static/css 에 있습니다. */
.ca-attach-btn, .ca-files, .ca-composer, .ca-viewer {
  --ca-accent: var(--action, var(--cobalt, var(--blue, #2458d6)));
  --ca-surface: var(--surface, #fff);
  --ca-soft: var(--surface-soft, var(--gray, #f4f6f9));
  --ca-line: var(--line-strong, var(--line, #c9d1dc));
  --ca-text: var(--text, #17202e);
  --ca-muted: var(--muted, #4b5565);
  --ca-red: var(--red, #c42b1c);
  --ca-red-soft: var(--red-soft, #fdeceb);
  --ca-green: var(--green, #0f7a43);
}
.ca-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* 첨부 버튼 */
.ca-attach-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; align-self: stretch; min-width: 44px; min-height: 44px;
  padding: 0 10px; border: 1px solid var(--ca-line); border-radius: 8px; background: var(--ca-surface); color: var(--ca-muted); cursor: pointer; }
.ca-attach-btn:hover:not(:disabled) { color: var(--ca-accent); border-color: var(--ca-accent); }
.ca-attach-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--ca-accent) 35%, transparent); outline-offset: 1px; }
.ca-attach-btn:disabled { opacity: .5; cursor: not-allowed; }
.ca-attach-btn .ca-icon { width: 20px; height: 20px; }

/* 보내기 전 목록 */
.ca-composer { flex: none; display: grid; gap: 6px; min-width: 0; }
.ca-tray { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 196px; overflow-y: auto; overscroll-behavior: contain; }
.ca-tray[hidden] { display: none; }
.ca-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px; border: 1px solid var(--ca-line); border-radius: 8px; background: var(--ca-surface); color: var(--ca-text); }
.ca-item.is-error { border-color: var(--ca-red); background: var(--ca-red-soft); }
.ca-item-thumb { width: 44px; height: 44px; flex: none; object-fit: cover; border-radius: 6px; background: var(--ca-soft); }
.ca-item-type, .ca-file-type { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 6px; background: var(--ca-soft);
  color: var(--ca-accent); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.ca-item-main { display: grid; gap: 2px; flex: 1; min-width: 0; }
.ca-item-name, .ca-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.ca-item-info { color: var(--ca-muted); font-size: 12px; overflow-wrap: anywhere; }
.ca-item.is-error .ca-item-info { color: var(--ca-red); font-weight: 600; }
.ca-item.is-done .ca-item-info { color: var(--ca-green); }
.ca-item-progress { width: 100%; height: 6px; accent-color: var(--ca-accent); }
.ca-item-btn { display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 36px; min-width: 36px; justify-content: center; padding: 0 8px;
  border: 1px solid var(--ca-line); border-radius: 6px; background: var(--ca-surface); color: var(--ca-text); font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.ca-item-btn:hover:not(:disabled) { border-color: var(--ca-accent); color: var(--ca-accent); }
.ca-item-remove { color: var(--ca-muted); }
.ca-status { margin: 0; color: var(--ca-muted); font-size: 12px; }
.ca-status.is-error { color: var(--ca-red); font-weight: 600; }
.ca-hint { margin: 0; color: var(--ca-muted); font-size: 11.5px; line-height: 1.5; }
.ca-status.ca-remind { animation: ca-remind .5s ease 2; border-radius: 4px; }
@keyframes ca-remind { 50% { background: var(--ca-red-soft); } }
@media (prefers-reduced-motion: reduce) { .ca-status.ca-remind { animation: none; text-decoration: underline; } }
.ca-dragging { outline: 2px dashed var(--ca-accent, #2458d6); outline-offset: -4px; }

/* 메시지 안의 첨부 */
.ca-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-width: 100%; }
.chat-msg.is-mine .ca-files { justify-content: flex-end; }
.ca-thumb { display: block; padding: 0; border: 1px solid var(--ca-line); border-radius: 10px; overflow: hidden; background: var(--ca-soft); cursor: zoom-in; line-height: 0; max-width: 100%; }
.ca-thumb img { display: block; max-width: 100%; height: auto; object-fit: cover; }
.ca-thumb:focus-visible { outline: 3px solid var(--ca-accent); outline-offset: 2px; }
.ca-thumb.is-broken { padding: 12px; line-height: 1.5; color: var(--ca-muted); font-size: 12px; cursor: default; }
.ca-file { display: flex; align-items: center; gap: 10px; width: min(320px, 100%); padding: 8px 10px; border: 1px solid var(--ca-line); border-radius: 10px; background: var(--ca-surface); color: var(--ca-text); }
.ca-file-meta { display: grid; gap: 2px; flex: 1; min-width: 0; text-align: left; }
.ca-file-size { color: var(--ca-muted); font-size: 12px; }
.ca-file-dl { display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 36px; padding: 0 10px; border: 1px solid var(--ca-line); border-radius: 6px;
  background: var(--ca-surface); color: var(--ca-accent); font-size: 12px; font-weight: 700; text-decoration: none; }
.ca-file-dl:hover { border-color: var(--ca-accent); text-decoration: none; }

/* 크게 보기 */
.ca-viewer { width: min(1100px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 12px; background: #0d1522; color: #fff; overflow: hidden; }
.ca-viewer[open] { display: flex; flex-direction: column; }
.ca-viewer::backdrop { background: rgba(6, 12, 22, .82); }
.ca-viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(255, 255, 255, .06); }
.ca-viewer-name { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 650; color: #fff; }
.ca-viewer-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 8px;
  background: none; color: #fff; font: inherit; font-size: 13px; font-weight: 650; text-decoration: none; cursor: pointer; }
.ca-viewer-btn:hover { background: rgba(255, 255, 255, .12); text-decoration: none; color: #fff; }
.ca-viewer-img { display: block; max-width: 100%; max-height: calc(100vh - 110px); margin: auto; object-fit: contain; }
@media (max-width: 640px) {
  .ca-viewer { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .ca-viewer-btn span { display: none; }
  .ca-viewer-img { max-height: calc(100dvh - 64px); }
  .ca-file { width: 100%; }
}
