* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { overflow-x: hidden; width: 100%; max-width: 100vw; touch-action: manipulation; }
input, button, select, textarea { font-size: 16px; }

:root {
  --bg: #0a0a12;
  --card: #12121e;
  --border: #1e1e30;
  --text: #e0e0e8;
  --sub: #777;
  --accent1: #6c5ce7;
  --accent2: #00cec9;
  --gradient: linear-gradient(135deg, #6c5ce7, #00cec9);
  --danger: #ff6b6b;
  --success: #00b894;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header { text-align: center; padding: 36px 20px 12px; }
.header h1 {
  font-size: 2.6rem; font-weight: 900;
  background: var(--gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: -1px;
}
.header p {
  margin-top: 6px; font-size: 0.9rem; font-weight: 600;
  background: var(--gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}

.container { width: 100%; max-width: 540px; padding: 16px 16px; overflow-x: hidden; word-break: break-word; }

/* 초기 선택 */
#modeSelect { display: flex; gap: 10px; width: 100%; }
.mode-card {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center;
  padding: 28px 12px; border: 2px solid var(--border); border-radius: 18px;
  background: var(--card); color: var(--text); cursor: pointer; transition: all 0.25s; text-align: center;
}
.mode-card:hover { border-color: var(--accent1); background: #1a1630; transform: translateY(-2px); }
.mode-icon { font-size: 3rem; margin-bottom: 12px; }
.mode-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.mode-desc { font-size: 0.8rem; color: var(--sub); }

.back-btn {
  background: var(--danger); border: none; color: #fff; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; padding: 6px 14px; margin-bottom: 14px; border-radius: 8px;
  transition: opacity 0.2s;
}
.back-btn:hover { opacity: 0.85; }

.panel { display: none; }
.panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; overflow: hidden; }

/* 드롭존 */
.drop-zone {
  border: 2px dashed #2a2a40; border-radius: 12px; padding: 40px 20px;
  text-align: center; cursor: pointer; transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent1); background: #1a1630; }
.drop-zone .icon { font-size: 2.5rem; margin-bottom: 10px; }
.drop-zone p { color: var(--sub); font-size: 0.9rem; }
.drop-zone input { display: none; }

/* 아이템 리스트 */
.item-list { display: none; margin-top: 16px; max-height: 300px; overflow-y: auto; }
.item-block {
  display: flex; align-items: center;
  padding: 10px 12px; background: #0e0e1a; border-radius: 8px; margin-bottom: 6px; font-size: 0.85rem;
}
.item-block .badge {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  font-size: 0.65rem; font-weight: 700; flex-shrink: 0; margin-right: 8px;
}
.item-block .badge.file { background: #1a1630; color: var(--accent1); }
.item-block .badge.text { background: #0a2020; color: var(--accent2); }
.item-block .badge.image { background: #1a1a0a; color: #f59e0b; }
.item-block .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.item-block .meta { color: var(--sub); white-space: nowrap; font-size: 0.8rem; margin-left: 8px; flex-shrink: 0; }
.item-block .remove {
  margin-left: 8px; color: var(--danger); cursor: pointer; font-size: 1.1rem;
  border: none; background: none; padding: 0 4px; flex-shrink: 0;
}

.file-summary { display: none; margin-top: 8px; font-size: 0.85rem; color: var(--sub); text-align: right; }
.add-more {
  padding: 8px 16px; background: #1a1a2e; border: 1px dashed #333; border-radius: 8px;
  color: var(--sub); font-size: 0.85rem; cursor: pointer; text-align: center;
}
.add-more:hover { border-color: var(--accent1); color: var(--text); }

/* 공유 모드 */
.share-mode { display: flex; gap: 8px; margin-top: 14px; justify-content: center; }
.share-toggle {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 10px; background: #0e0e1a; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: all 0.2s; min-width: 0;
}
.share-toggle.active { border-color: var(--accent1); background: #1a1630; }
.share-toggle input { display: none; }
.share-toggle-icon { font-size: 1.3rem; margin-bottom: 2px; }
.share-toggle-label { font-size: 0.75rem; font-weight: 700; color: var(--sub); }
.share-toggle.active .share-toggle-label { color: var(--text); }


/* 공유 버튼 */
.share-btn {
  width: 100%; padding: 14px; margin-top: 16px; background: var(--gradient);
  color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s;
}
.share-btn:hover { opacity: 0.9; }
.share-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* 상태 모달 */
.status-modal {
  margin-top: 24px; text-align: center; padding: 24px 16px;
  background: #0d0d1a; border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden; word-break: break-word;
}

.circle-wrap { position: relative; width: 140px; height: 140px; margin: 0 auto 20px; }
.circle-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.circle-bg { fill: none; stroke: #1e1e30; stroke-width: 8; }
.circle-progress {
  fill: none; stroke: url(#progressGradient); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset 0.4s ease;
}
.circle-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
}

.spinner { width: 36px; height: 36px; border: 3px solid #1e1e30; border-top-color: var(--accent1); border-right-color: var(--accent2); border-radius: 50%; animation: spin 1s linear infinite; }
.waiting-spinner { display: none; text-align: center; margin-bottom: 20px; }
.spinner-large { width: 64px; height: 64px; border: 4px solid #1e1e30; border-top-color: var(--accent1); border-right-color: var(--accent2); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.circle-percent { font-size: 2rem; font-weight: 900; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.circle-check { font-size: 3rem; font-weight: 900; color: var(--success); }

.status-label { font-size: 0.85rem; color: var(--sub); margin-bottom: 8px; }
.peer-count { font-size: 0.8rem; color: var(--accent2); margin-top: 6px; margin-bottom: 4px; }
.status-code {
  font-size: 2.4rem; font-weight: 900; letter-spacing: 6px;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; font-family: 'Courier New', monospace; margin-bottom: 4px;
  word-break: break-all; overflow-wrap: break-word;
}

.code-buttons { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.copy-btn { padding: 8px 20px; background: #1e1e30; color: #ccc; border: 1px solid #333; border-radius: 8px; cursor: pointer; font-size: 0.85rem; }
.copy-btn:hover { background: #2a2a40; }

.qr-wrap { display: block; margin: 16px auto 8px; padding: 12px; background: #fff; border-radius: 10px; width: fit-content; }
.qr-wrap canvas { display: block; width: 160px; height: 160px; }

.transfer-info { margin-top: 16px; }
.transfer-speed { font-size: 1.1rem; font-weight: 700; color: var(--accent2); }
.transfer-eta { font-size: 0.85rem; color: var(--sub); margin-top: 4px; }
.transfer-file { font-size: 0.8rem; color: #555; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.complete-msg { margin-top: 16px; font-size: 1.1rem; font-weight: 700; color: var(--success); }

/* 다중 파일 프로그레스 */
.file-progress-list { margin-top: 16px; }
.file-progress-item { background: #0e0e1a; border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.file-progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 0.85rem; }
.file-progress-header .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 10px; text-align: left; }
.file-progress-header .info { color: var(--sub); font-size: 0.8rem; white-space: nowrap; }
.file-bar-wrap { background: #1a1a2e; border-radius: 6px; height: 8px; overflow: hidden; }
.file-bar { height: 100%; background: var(--gradient); border-radius: 6px; width: 0%; transition: width 0.3s; }
.file-progress-footer { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.75rem; color: var(--sub); }
.file-progress-item.completed .file-bar { width: 100% !important; }
.file-progress-item.completed .file-progress-header .info { color: var(--success); }
.file-progress-item.pending { opacity: 0.5; }
.multi-summary { text-align: center; margin-top: 12px; font-size: 0.85rem; color: var(--sub); }

/* 다수 모드 송신자 파일 목록 */
.send-file-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #0e0e1a;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  gap: 8px;
}

.sfr-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.sfr-size {
  color: var(--sub);
  font-size: 0.8rem;
  white-space: nowrap;
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

.sfr-count {
  color: var(--accent2);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* 받기 패널 */
.code-input-wrap { display: flex; gap: 8px; }
.code-input {
  flex: 1; min-width: 0; padding: 14px 12px; background: #0e0e1a;
  border: 2px solid var(--border); border-radius: 12px; color: #fff;
  font-size: 1.1rem; font-weight: 700; letter-spacing: 3px; text-align: center;
  text-transform: uppercase; outline: none;
}
.code-input:focus { border-color: var(--accent1); }
.code-input::placeholder { letter-spacing: 2px; font-weight: 400; color: #444; }
.join-btn {
  padding: 14px 24px; background: var(--gradient); color: #fff; border: none;
  border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.join-btn:hover { opacity: 0.9; }
.join-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* 받은 텍스트 */
.received-text { display: none; margin-top: 20px; background: #0e0e1a; border-radius: 12px; padding: 20px; }
.received-text .type-badge {
  display: inline-block; padding: 4px 12px; border-radius: 6px;
  font-size: 0.8rem; font-weight: 700; margin-bottom: 12px;
}
.received-text-content {
  background: #0a0a12; border-radius: 8px; padding: 14px; white-space: pre-wrap;
  word-break: break-all; font-size: 0.95rem; line-height: 1.6; max-height: 300px; overflow-y: auto;
}
.text-copy-btn {
  margin-top: 10px; width: 100%; padding: 10px; background: #1e1e30; color: #ccc;
  border: 1px solid #333; border-radius: 8px; cursor: pointer; font-size: 0.9rem;
}
.text-copy-btn:hover { background: #2a2a40; }

.accept-btn {
  width: 100%; margin-top: 12px; padding: 12px; background: var(--gradient);
  color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.accept-btn:hover { opacity: 0.9; }

/* 다운로드 */
.recv-complete { margin-top: 16px; }
.download-item-wrap { background: #0e0e1a; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.download-item-wrap .download-item { background: none; border-radius: 0; padding: 0; margin-bottom: 0; }
.download-item {
  display: flex; align-items: center;
  padding: 10px 12px; background: #0a0a12; border-radius: 8px; margin-bottom: 6px; font-size: 0.85rem;
}
.download-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px; }
.download-item .meta { color: var(--sub); font-size: 0.8rem; width: 60px; text-align: right; margin-right: 8px; white-space: nowrap; flex-shrink: 0; }
.download-item .dl-btn {
  padding: 8px 14px; background: var(--gradient); color: #fff; border: none;
  border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  width: 72px; text-align: center; flex-shrink: 0;
}
.download-item .dl-btn:hover { opacity: 0.9; }
.download-item-wrap .file-bar-wrap { margin-top: 6px; }
.download-item-wrap .file-progress-footer { margin-top: 4px; }

/* 에러 */
.error-msg {
  display: none; margin-top: 12px; padding: 12px; background: #200a0a;
  border: 1px solid #401a1a; border-radius: 8px; color: var(--danger); font-size: 0.9rem; text-align: center;
}

/* 상태 점 */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #555; vertical-align: middle; }
.dot.waiting { background: #f59e0b; animation: pulse 1.5s infinite; }
.dot.connected { background: var(--success); }
.dot.active { background: var(--accent2); animation: pulse 0.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* 폭파 모달 */
.boom-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85); z-index: 2000;
  justify-content: center; align-items: center;
}

.boom-content { text-align: center; animation: boomIn 0.5s ease-out; }

.boom-icon {
  font-size: 6rem; animation: boomShake 0.6s ease-out;
}

.boom-text {
  margin-top: 16px; font-size: 1.2rem; font-weight: 700; color: #ff6b6b;
  animation: boomFade 0.8s ease-out;
}

@keyframes boomIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

/* 미리보기 모달 */
.preview-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85); z-index: 1500;
  justify-content: center; align-items: center; padding: 16px;
}
.preview-modal {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  width: 100%; max-width: 500px; max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.preview-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.preview-title { font-size: 0.9rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-close {
  background: none; border: none; color: var(--sub); font-size: 1.5rem; cursor: pointer;
}
.preview-close:hover { color: var(--text); }
.preview-body {
  flex: 1; overflow-y: auto; text-align: center; min-height: 200px;
  display: flex; align-items: center; justify-content: center;
}
.preview-body img {
  max-width: 100%; max-height: 60vh; border-radius: 8px;
}
.preview-body .preview-text {
  text-align: left; background: #0a0a12; border-radius: 8px; padding: 14px;
  white-space: pre-wrap; word-break: break-all; font-size: 0.85rem;
  line-height: 1.6; color: var(--sub); max-height: 60vh; overflow-y: auto; width: 100%;
}
.preview-nav {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  margin-top: 12px;
}
.preview-nav-btn {
  width: 36px; height: 36px; border-radius: 50%; background: #1e1e30; color: #fff;
  border: none; font-size: 1rem; cursor: pointer;
}
.preview-nav-btn:hover { background: var(--accent1); }
.preview-nav span { font-size: 0.85rem; color: var(--sub); }
.preview-body { overflow: hidden; position: relative; }

.swipe-guide {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #fff; padding: 8px 20px;
  border-radius: 20px; font-size: 0.8rem; white-space: nowrap;
  animation: guideAppear 0.5s ease-out, guideFade 0.5s ease-in 1.5s forwards;
}

@keyframes guideAppear {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes guideFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.preview-dl-btn {
  margin-top: 12px; width: 100%; padding: 10px; background: var(--gradient);
  color: #fff; border: none; border-radius: 10px; font-size: 0.9rem; font-weight: 700; cursor: pointer;
}
.preview-dl-btn:hover { opacity: 0.85; }

/* 썸네일 아이콘 */
.thumb-row { display: flex; gap: 4px; margin-top: 6px; }
.thumb-img {
  width: 40px; height: 40px; border-radius: 4px; object-fit: cover; cursor: pointer;
  border: 1px solid var(--border);
}
.thumb-img:hover { border-color: var(--accent1); }

@keyframes boomShake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-15deg); }
  40% { transform: rotate(15deg); }
  60% { transform: rotate(-10deg); }
  80% { transform: rotate(10deg); }
}

@keyframes boomFade {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.boom-btn {
  margin-top: 24px; padding: 10px 40px; background: var(--danger); color: #fff;
  border: none; border-radius: 10px; font-size: 1rem; font-weight: 700;
  cursor: pointer; animation: boomFade 1s ease-out;
}
.boom-btn:hover { opacity: 0.85; }

/* 리셋 */
.exit-btn {
  display: none; margin-top: 14px; width: 100%; padding: 12px; background: var(--danger);
  color: #fff; border: none; border-radius: 10px; cursor: pointer; font-size: 0.9rem; font-weight: 700;
  transition: opacity 0.2s;
}
.exit-btn:hover { opacity: 0.85; }

/* 전송 중지 */
.stop-btn {
  width: 100%; margin-top: 16px; padding: 12px; background: var(--gradient); color: #fff;
  border: none; border-radius: 10px; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s;
}
.stop-btn:hover { opacity: 0.85; }

/* 히스토리 */
.history-section {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.history-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sub);
}

.history-clear {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.75rem;
  cursor: pointer;
}

.history-clear:hover { opacity: 0.7; }

.history-scroll {
  max-height: 200px;
  overflow-y: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.history-row td {
  padding: 8px 8px;
  border-bottom: 1px solid #1a1a2e;
  vertical-align: middle;
}

.history-row:last-child td { border-bottom: none; }

.h-icon { width: 24px; padding-left: 14px !important; }
.h-files {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.h-size { color: var(--sub); white-space: nowrap; }
.h-date { color: var(--sub); white-space: nowrap; font-size: 0.75rem; }

/* 모달 */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); z-index: 1000;
  justify-content: center; align-items: center; padding: 16px; overflow: hidden;
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; width: calc(100% - 32px); max-width: 440px; position: relative;
  box-sizing: border-box; overflow: hidden; margin: 0 auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--sub); font-size: 1.5rem; cursor: pointer; padding: 0 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-textarea {
  width: 100%; max-width: 100%; min-height: 150px; padding: 14px; background: #0e0e1a;
  border: 2px solid var(--border); border-radius: 12px; color: var(--text); font-size: 0.95rem;
  font-family: inherit; resize: vertical; outline: none; transition: border-color 0.2s; box-sizing: border-box;
}
.modal-textarea:focus { border-color: var(--accent1); }
.modal-textarea::placeholder { color: #444; }
.modal-hint { margin-top: 6px; font-size: 0.75rem; color: #444; text-align: right; }
.modal-submit {
  width: 100%; padding: 12px; margin-top: 14px; background: var(--gradient);
  color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.modal-submit:hover { opacity: 0.9; }

.footer { margin-top: auto; padding: 20px; text-align: center; color: #888; font-size: 0.8rem; }
.footer-brand { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-weight: 700; }

@media (max-width: 480px) {
  .header h1 { font-size: 1.8rem; }
  .header { padding: 24px 16px 8px; }
  .container { padding: 12px 12px; }
  .card { padding: 18px 14px; }
  .status-modal { padding: 20px 12px; }
  .status-code { font-size: 1.8rem; letter-spacing: 4px; }
  .code-input { font-size: 1rem; letter-spacing: 2px; padding: 12px 10px; }
  .join-btn { padding: 12px 16px; font-size: 0.9rem; }
  .mode-card { padding: 24px 12px; }
  .mode-title { font-size: 1.1rem; }
  .mode-icon { font-size: 2.4rem; }
  .circle-wrap { width: 120px; height: 120px; }
  .circle-percent { font-size: 1.6rem; }
  .copy-btn { padding: 8px 16px; }
  .ai-chat-modal { width: 95vw; height: 80vh; }
}

/* ════ 보안 경고 ════ */
.security-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: center;
}
.security-modal {
  width: min(420px, 90vw); background: var(--card);
  border-radius: 16px; overflow: hidden;
  border: 2px solid #e17055;
  box-shadow: 0 8px 40px rgba(225, 112, 85, 0.3);
}
.security-header {
  padding: 16px; text-align: center;
  font-size: 1.1rem; font-weight: 700;
  background: rgba(225, 112, 85, 0.15);
  border-bottom: 1px solid var(--border);
}
.security-file {
  padding: 10px 16px; font-size: 0.8rem; color: var(--sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.security-list { padding: 0 16px 12px; }
.security-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.security-item:last-child { border-bottom: none; }
.security-icon { font-size: 1rem; flex-shrink: 0; }
.security-detail { color: var(--text); }
.security-actions {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.security-btn {
  flex: 1; padding: 10px; border: none; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.security-btn.cancel { background: #636e72; color: #fff; }
.security-btn.proceed { background: #e17055; color: #fff; }
.security-btn:hover { opacity: 0.9; }

/* 아이템 경고 표시 */
.item-block.has-warning { border-left: 3px solid #e17055; }
.security-warn {
  cursor: pointer; font-size: 0.9rem; flex-shrink: 0;
  animation: pulse 2s infinite;
}

/* ════ AI 채팅 모달 ════ */
.ai-chat-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  justify-content: center; align-items: center;
}
.ai-chat-modal {
  width: min(480px, 95vw); height: 75vh;
  background: var(--card); border-radius: 16px;
  display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.ai-chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: rgba(108, 92, 231, 0.1);
}
.ai-chat-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.ai-chat-file {
  flex: 1; font-size: 0.75rem; color: var(--sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-chat-close {
  background: none; border: none; color: var(--sub); font-size: 1.4rem;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.ai-chat-close:hover { color: var(--text); }

.ai-chat-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.ai-chat-welcome {
  text-align: center; padding: 40px 16px; color: var(--sub);
}
.ai-chat-welcome-icon { font-size: 2.5rem; margin-bottom: 12px; }
.ai-chat-welcome-text { font-size: 0.85rem; line-height: 1.6; }

.ai-msg {
  max-width: 88%; padding: 10px 14px;
  border-radius: 12px; font-size: 0.85rem; line-height: 1.6;
  word-break: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff; border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--inputBg); color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-msg.bot .ai-page-ref {
  display: inline-block; margin-top: 6px;
  font-size: 0.7rem; color: var(--accent2); opacity: 0.8;
}
.ai-msg.system {
  align-self: center; font-size: 0.75rem; color: var(--sub);
  background: none; padding: 4px;
}
.ai-typing {
  align-self: flex-start; padding: 10px 14px;
  background: var(--inputBg); border-radius: 12px;
  font-size: 0.85rem; color: var(--sub);
}
.ai-typing::after {
  content: ''; display: inline-block;
  animation: aiDots 1.2s infinite;
}
@keyframes aiDots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
}

.ai-chat-input-wrap {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
.ai-chat-input {
  flex: 1; background: var(--inputBg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text);
  font-size: 0.85rem; outline: none;
}
.ai-chat-input:focus { border-color: var(--accent1); }
.ai-chat-send {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border: none; color: #fff; padding: 10px 18px;
  border-radius: 8px; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; white-space: nowrap;
}
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* AI 버튼 (썸네일 옆) */
.ai-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border: none; cursor: pointer; font-size: 1rem;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.4);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.ai-btn:hover { transform: scale(1.15); }
.ai-btn.processing {
  animation: pulse 1s infinite;
  pointer-events: none;
}
/* 수신자 AI분석 버튼 (다운로드와 동일 스타일, 색상만 다름) */
.ai-dl-btn {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe) !important;
}

/* 송신자 공유 화면 AI 버튼 */
.sfr-ai-btn {
  padding: 4px 10px; border: none; border-radius: 4px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff; font-size: 0.7rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  width: 52px; text-align: center; flex-shrink: 0;
}
.sfr-ai-btn:hover { opacity: 0.9; }

/* PDF 아닌 파일의 빈 공간 (테이블 정렬 유지) */
.sfr-ai-empty {
  display: inline-block;
  width: 52px; flex-shrink: 0;
}

/* ════ 송신자 인라인 AI 채팅 ════ */
.ai-inline {
  margin-top: 16px; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  background: var(--card);
}
.ai-inline-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 0.85rem; font-weight: 700;
  background: rgba(108, 92, 231, 0.1);
  border-bottom: 1px solid var(--border);
}
.ai-inline-file {
  flex: 1; font-size: 0.7rem; color: var(--sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 400;
}
.ai-inline-body {
  max-height: 250px; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 60px;
}
.ai-inline-body:empty::after {
  content: 'PDF를 분석했습니다. 질문해 보세요!';
  color: var(--sub); font-size: 0.8rem; text-align: center;
  padding: 16px 0;
}
.ai-inline-input-wrap {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border);
}
