/* =============================================================================
   PALOMA-TALK v0.0.5 — 보안 메신저 UI
   - 원본 시뮬레이터(palomatalk_with_cameleon_4.html)의 스타일을 그대로 이식한다:
     app-frame·topbar 로고(--paloma-img)·paloma-hero·info-box·option-row/switch·
     waiting/spinner·compact-waiting·link-display·qr-wrap·secure-strip·
     threshold-banner·dissolving·file 파이프라인·file-ttl·ttl-selector·모달 6종 상당.
   - 원본에 없는 유지 항목: 알고리즘·경로 보조 스트립, 1회 안내 배너, 재연결 스트립.
     (개발자 패널 스타일은 v0.0.6에서 렌더되지 않는다 — DEV UI 제거, 명세 §17.)
   - 라이트 전용. prefers-reduced-motion 대응 유지.
   ============================================================================= */

:root {
  /* 채팅 팔레트 (원본 시뮬레이터 :root 그대로) */
  --c-bg: #f2f2f2;
  --c-surface: #ffffff;
  --c-surface-2: #fafafa;
  --c-border: #cccccc;
  --c-border-strong: #999999;
  --c-text: #1a1a1a;
  --c-text-2: #555555;
  --c-text-3: #888888;
  --c-muted: #e6e6e6;
  --c-disabled: #d9d9d9;
  --c-accent: #333333;

  /* 상태 색 (원본 하드코딩 색을 토큰화) */
  --good: #2db84a;
  --bad: #c62828;

  --radius: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  /* PALOMA 심볼 (원본 31행 — 로컬 에셋 참조) */
  --paloma-img: url("./PALOMA.png");
}

* {
  box-sizing: border-box;
}

/* hidden 속성은 어떤 display 선언보다 우선한다 (v0.0.3의 방어 규칙 계승) */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* =============================================================================
   프레임 (원본 .app-frame — 아이폰 14/15 사이즈 390×844)
   ============================================================================= */

.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 20px;
}

.app-frame {
  width: 390px;
  max-width: 100%;
  height: min(844px, calc(100vh - 20px));
  min-height: 600px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow);
}

/* =============================================================================
   공통 UI (원본 topbar·body·btn·input·info-box·link-display·qr-wrap)
   ============================================================================= */

.topbar {
  border-bottom: 1px solid var(--c-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--c-surface-2);
  min-height: 48px;
}

.topbar .logo {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar .logo::before {
  content: "";
  display: inline-block;
  width: 26px;
  height: 20px;
  background-image: var(--paloma-img);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

/* Landing 화면 PALOMA 심볼 hero (원본 145-152행) */
.paloma-hero {
  width: 160px;
  height: 120px;
  margin: 4px auto 8px;
  background-image: var(--paloma-img);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.topbar .icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface);
  font-size: 14px;
  color: var(--c-text-2);
  cursor: pointer;
  font-family: inherit;
}

.topbar .icon-btn:hover {
  background: var(--c-muted);
}

.body {
  padding: 24px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  line-height: 1.35;
}

.section-sub {
  font-size: 13px;
  color: var(--c-text-2);
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: background 0.1s;
}

.btn:hover {
  background: var(--c-muted);
}

.btn.primary {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}

.btn.primary:hover {
  background: #000;
}

.btn.full {
  width: 100%;
}

.btn.sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn.disabled,
.btn:disabled {
  background: var(--c-disabled);
  color: var(--c-text-3);
  border-color: var(--c-border);
  cursor: not-allowed;
}

.btn.disabled:hover,
.btn:disabled:hover {
  background: var(--c-disabled);
}

.btn.ghost {
  background: transparent;
  border-color: var(--c-border);
  color: var(--c-text-2);
}

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  font-family: inherit;
}

.input::placeholder {
  color: var(--c-text-3);
}

.input:focus {
  outline: none;
  border-color: var(--c-text);
}

.label {
  font-size: 12px;
  color: var(--c-text-2);
  margin-bottom: 4px;
  display: block;
}

.info-box {
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--c-text-2);
}

.info-box.dashed {
  border-style: dashed;
}

.info-box ul {
  margin: 8px 0 0 0;
  padding-left: 18px;
}

.info-box li {
  margin-bottom: 4px;
}

/* 세션 생성 실패 배너 (브리프 §3 — landing 오류 배너) */
.info-box.error-box {
  border-color: var(--bad);
  color: var(--bad);
  background: rgba(198, 40, 40, 0.06);
}

.link-display {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--c-surface-2);
}

.link-display .url {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--c-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.divider {
  height: 1px;
  background: var(--c-border);
  margin: 8px 0;
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  border-radius: var(--radius);
}

.qr-wrap canvas {
  background: #fff;
  border: 1px solid var(--c-border);
  padding: 6px;
  border-radius: 4px;
  max-width: 130px;
  height: auto;
}

.qr-wrap .qr-cap {
  font-size: 11px;
  color: var(--c-text-3);
}

/* host-waiting 컴팩트 모드 (원본 240-253행 — 스크롤 없이 한 화면에) */
.body.compact-waiting {
  padding: 14px 18px 16px;
  gap: 10px;
}

.body.compact-waiting .section-title {
  font-size: 15px;
  margin: 0;
}

.body.compact-waiting .section-sub {
  font-size: 12px;
  margin: 0;
}

.body.compact-waiting .qr-wrap {
  padding: 8px;
  gap: 4px;
}

.body.compact-waiting .qr-wrap canvas {
  max-width: 118px;
  padding: 4px;
}

.body.compact-waiting .qr-wrap .qr-cap {
  font-size: 10px;
  line-height: 1.2;
}

.body.compact-waiting .waiting {
  padding: 10px 12px;
  gap: 6px;
}

.body.compact-waiting .waiting .spinner {
  width: 26px;
  height: 26px;
}

.body.compact-waiting .waiting .msg {
  font-size: 12px;
}

.body.compact-waiting .divider {
  margin: 2px 0;
}

.body.compact-waiting .label {
  margin-bottom: 2px;
}

.body.compact-waiting .link-display {
  padding: 6px 10px;
}

.body.compact-waiting .info-box {
  padding: 8px 12px;
  font-size: 12px;
}

.waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 16px;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface-2);
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-text);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.waiting .msg {
  font-size: 13px;
  color: var(--c-text-2);
}

/* 세션 TTL 카운트다운 (명세 §22.3 — 원본에 없는 유지 항목) */
.countdown {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--c-text-2);
}

.countdown.urgent {
  color: var(--bad);
  font-weight: 700;
}

.error-icon {
  width: 48px;
  height: 48px;
  border: 2px solid var(--c-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px auto;
  font-weight: 600;
}

.center-body {
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* joined 화면 — 암호 채널 준비 진행 표시 (브리프 D2) */
.handshake-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--c-text-2);
  padding: 6px 12px;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface-2);
}

.handshake-status.ready {
  color: var(--good);
  border-color: var(--good);
  font-weight: 700;
}

/* 옵션 토글 — create 화면 (원본 554-588행 option-row + switch) */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface-2);
}

.option-row .opt-text {
  min-width: 0;
}

.option-row .opt-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
}

.option-row .opt-desc {
  font-size: 11px;
  color: var(--c-text-3);
  margin-top: 2px;
  line-height: 1.4;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--c-disabled);
  border: 1px solid var(--c-border-strong);
  border-radius: 22px;
  transition: background 0.2s, border-color 0.2s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background: var(--c-text);
  border-color: var(--c-text);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* =============================================================================
   채팅 헤더·secure-strip (원본 281-311행)
   ============================================================================= */

.chat-header {
  border-bottom: 1px solid var(--c-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--c-surface-2);
}

.chat-header .peer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-muted);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--c-text-2);
  font-weight: 600;
}

/* joined 화면의 큰 아바타 (원본 인라인 style 56px 상당) */
.avatar.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

.peer-name {
  font-size: 13px;
  font-weight: 600;
}

.peer-status {
  font-size: 11px;
  color: var(--c-text-3);
}

.peer-status.online::before {
  content: "● ";
}

.peer-status.offline::before {
  content: "○ ";
}

.secure-strip {
  background: #1a1a1a;
  color: #fff;
  font-size: 10px;
  padding: 4px 12px;
  text-align: center;
  letter-spacing: 0.5px;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.secure-strip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* 알고리즘·전송 경로 보조 스트립 — 경로 표시는 명세 §18.3 필수 */
.secure-substrip {
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-2);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.3px;
  padding: 3px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.secure-substrip .substrip-sep {
  color: var(--c-text-3);
}

/* MITM 미탐지 1회 안내 배너 (명세 §18.2 — 브리프 D7 유지) */
.security-banner {
  background: #2a2a2a;
  color: #fff;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #000;
}

.security-banner span {
  flex: 1;
}

/* 누적 임계 배너 (원본 313-336행 threshold-banner 그대로 — 브리프 D8) */
.threshold-banner {
  display: none;
  background: #2a2a2a;
  color: #fff;
  padding: 8px 12px;
  font-size: 12px;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #000;
}

.threshold-banner.show {
  display: flex;
}

.threshold-banner .banner-text {
  flex: 1;
  line-height: 1.3;
}

.banner-action {
  background: #fff;
  color: #1a1a1a;
  border: none;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.banner-action:hover {
  background: #ddd;
}

.banner-close {
  background: transparent;
  color: #aaa;
  border: 1px solid #555;
  padding: 0 6px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 3px;
  line-height: 1;
  height: 22px;
  flex-shrink: 0;
}

.banner-close:hover {
  color: #fff;
  border-color: #fff;
}

/* 재연결 배지 — 원본에 없는 실동작 유지 항목 (명세 §22.16) */
.reconnect-strip {
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 4px 12px;
  font-family: var(--mono);
}

/* =============================================================================
   채팅 본문·말풍선 (원본 338-433행)
   ============================================================================= */

.chat-body {
  flex: 1;
  padding: 16px;
  background: var(--c-bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 320px;
  transition: opacity 1.5s ease, filter 1.5s ease;
  position: relative;
}

.chat-body.dissolving {
  opacity: 0;
  filter: blur(4px);
  pointer-events: none;
}

/* 카멜레온 워터마크: QR 타일(위, 고정) · 텍스트 타일(아래, 드리프트) (원본 590-606행) */
.chat-body.watermarked {
  background-color: var(--c-bg);
  background-repeat: repeat, repeat;
  background-size: auto, auto;
  animation: watermark-drift 30s linear infinite;
}

@keyframes watermark-drift {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 0 0, 280px -180px;
  }
}

.system-msg {
  align-self: center;
  font-size: 11px;
  color: var(--c-text-3);
  background: var(--c-muted);
  padding: 4px 10px;
  border-radius: 12px;
  max-width: 90%;
  text-align: center;
}

.system-msg.notice {
  background: var(--c-text);
  color: #fff;
}

.system-msg.fresh {
  background: #fff;
  color: var(--c-text);
  border: 1px dashed var(--c-text);
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.msg-row.me {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.them {
  align-self: flex-start;
  align-items: flex-start;
}

.msg {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid var(--c-border);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-row.them .msg {
  background: var(--c-surface);
}

.msg-row.me .msg {
  background: var(--c-text);
  color: #fff;
  border-color: var(--c-text);
}

.msg-row.failed .msg {
  background: var(--c-surface);
  color: var(--c-text-2);
  border-color: var(--c-border-strong);
  border-style: dashed;
}

.msg-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
  font-size: 10px;
  color: var(--c-text-3);
}

.msg-row.me .msg-meta {
  flex-direction: row-reverse;
}

.msg-status {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: -0.5px;
}

.msg-status.sending {
  color: var(--c-text-3);
}

.msg-status.sent {
  color: var(--c-text-3);
}

.msg-status.read {
  color: var(--c-text);
  font-weight: 600;
}

.msg-status.failed {
  color: var(--c-text);
}

.retry-btn {
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--c-text-2);
}

.retry-btn:hover {
  background: var(--c-muted);
}

/* =============================================================================
   파일 카드 + 2단 파이프라인·TTL (원본 374-413행, 700-779행)
   ============================================================================= */

.file-msg {
  min-width: 200px;
  padding: 10px 12px !important;
}

.msg-row.me .file-msg {
  background: var(--c-text);
  color: #fff;
}

.msg-row.them .file-msg {
  background: var(--c-surface);
}

.file-msg .file-info {
  min-width: 0;
}

.file-msg .file-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-msg .file-name .file-emoji {
  font-size: 14px;
  margin-right: 4px;
  display: inline-block;
  vertical-align: -1px;
}

.file-msg .file-size {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 1px;
}

.file-action-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.file-msg .file-action {
  margin-top: 6px;
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}

.file-msg .file-action.disabled,
.file-msg .file-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.file-msg.purged {
  border: 1px dashed var(--c-border-strong);
  background: var(--c-muted) !important;
  color: var(--c-text-2) !important;
  font-style: italic;
}

/* 2단 파이프라인 (원본 Phase 2 — 암호화→전송 / 다운로드→복호화).
   진행바는 실제 chunk 카운트로만 그린다 (명세 §23.5 — 가짜 타이머 금지) */
.file-msg .file-pipeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.file-msg .pipeline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  line-height: 1;
}

.file-msg .pipeline-label {
  flex-shrink: 0;
  min-width: 56px;
  opacity: 0.8;
  font-family: var(--mono);
}

.file-msg .pipeline-track {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.msg-row.them .file-msg .pipeline-track {
  background: var(--c-muted);
}

.file-msg .pipeline-bar {
  height: 100%;
  width: 0;
  background: #fff;
  transition: width 0.12s linear;
}

.msg-row.them .file-msg .pipeline-bar {
  background: var(--c-text);
}

.file-msg .pipeline-bar.crypto-bar {
  /* 암호화 바: 살짝 다른 시각으로 강조 (원본) */
  background: linear-gradient(90deg, #fff, #ddd);
}

.msg-row.them .file-msg .pipeline-bar.crypto-bar {
  background: linear-gradient(90deg, #1a1a1a, #444);
}

.file-msg .pipeline-pct {
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
  font-family: var(--mono);
  opacity: 0.7;
}

.file-msg .pipeline-row.done .pipeline-bar {
  background: var(--good);
}

.msg-row.them .file-msg .pipeline-row.done .pipeline-bar {
  background: var(--good);
}

/* 파일 TTL 카운트다운 (원본 Phase 4) */
.file-msg .file-ttl {
  display: none;
  margin-top: 6px;
  font-size: 9px;
  font-family: var(--mono);
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  align-self: flex-start;
}

.msg-row.them .file-msg .file-ttl {
  background: var(--c-muted);
  color: var(--c-text-2);
}

.file-msg .file-ttl.active {
  display: inline-block;
}

.file-msg .file-ttl.urgent {
  background: var(--bad);
  color: #fff !important;
  animation: ttl-urgent 0.6s infinite alternate;
}

@keyframes ttl-urgent {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.55;
  }
}

.file-msg.expired {
  border: 1px dashed var(--bad) !important;
  background: rgba(198, 40, 40, 0.08) !important;
  color: var(--bad) !important;
  font-style: italic;
}

/* =============================================================================
   입력바·플러스 메뉴 (원본 435-476행)
   ============================================================================= */

.chat-input {
  border-top: 1px solid var(--c-border);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: var(--c-surface-2);
  align-items: center;
  position: relative;
}

.chat-input .input {
  flex: 1;
}

.chat-input.disabled {
  background: var(--c-disabled);
}

.chat-input.disabled .input {
  background: var(--c-disabled);
  color: var(--c-text-3);
}

.plus-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
  color: var(--c-text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.plus-btn:hover {
  background: var(--c-muted);
}

.plus-btn:disabled {
  background: var(--c-disabled);
  color: var(--c-text-3);
  cursor: not-allowed;
}

.plus-menu {
  position: absolute;
  bottom: 56px;
  left: 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
  display: none;
  min-width: 180px;
  overflow: hidden;
}

.plus-menu.show {
  display: block;
}

.plus-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 12px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--c-text);
}

.plus-menu button:hover {
  background: var(--c-muted);
}

/* 실제 파일 선택 input — 화면에는 숨기고 버튼으로 연다 (브리프 D3) */
.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* =============================================================================
   모달 (원본 478-513행 — 단일 프레임 앱이므로 fixed 백드롭으로 통일)
   ============================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 150;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
}

.modal h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.modal p {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--c-text-2);
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions .btn {
  flex: 1;
}

.modal-center {
  text-align: center;
}

/* 파일 보관 시간 (TTL) 선택기 — file-picker 내부 (원본 781-806행) */
.ttl-selector {
  margin: 8px 0 14px;
}

.ttl-selector .ttl-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 4px;
}

.ttl-selector .ttl-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ttl-selector .ttl-opt {
  flex: 1;
  min-width: 38px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 5px 4px;
  font-size: 10px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  color: var(--c-text-2);
  white-space: nowrap;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.ttl-selector .ttl-opt:hover {
  background: var(--c-muted);
}

.ttl-selector .ttl-opt.selected {
  background: var(--c-text);
  color: #fff;
  border-color: var(--c-text);
}

.ttl-selector .ttl-note {
  font-size: 10px;
  color: var(--c-text-3);
  margin-top: 4px;
  line-height: 1.35;
}

/* 파일 선택 목록 (원본 608-620행 — 실제 input[type=file]을 여는 버튼 1개로 재구성) */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 16px 0;
}

.file-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.file-option:hover {
  background: var(--c-muted);
}

.file-option .file-emoji {
  font-size: 22px;
}

.file-option .file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
}

.file-option .file-size {
  font-size: 11px;
  color: var(--c-text-3);
}

/* =============================================================================
   토스트 — 하단 중앙 검정 (원본 255-265행. 스택으로 확장 — 명세 §22.16)
   ============================================================================= */

.toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: #1a1a1a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 13px;
  max-width: 320px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =============================================================================
   개발자 패널 — 다크 콘솔 톤, v0.0.3 .log-area 계승 (명세 §18.3, §22.10, 브리프 D11)
   ============================================================================= */

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.toggle-row input {
  margin-top: 3px;
}

.dev-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  padding: 6px 10px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text-3);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
}

.dev-toggle:hover {
  color: var(--c-text);
  background: var(--c-muted);
}

.dev-panel {
  position: fixed;
  right: 16px;
  bottom: 56px;
  width: min(480px, calc(100vw - 32px));
  max-height: 72vh;
  overflow-y: auto;
  background: #0d131b;
  color: #cbd5e1;
  border: 1px solid #263242;
  border-radius: 10px;
  padding: 14px;
  z-index: 70;
  font-family: var(--mono);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.dev-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dev-panel-head strong {
  font-size: 13px;
  color: #e2e8f0;
}

.dev-section {
  border-top: 1px dashed #263242;
  padding: 10px 0;
}

.dev-section-title {
  font-size: 11px;
  color: #7d8ea6;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.dev-kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
  font-size: 11.5px;
}

.dev-kv span {
  color: #7d8ea6;
}

.dev-kv strong {
  color: #e2e8f0;
  font-weight: 600;
  word-break: break-all;
  text-align: right;
}

.dev-toggle-row {
  color: #cbd5e1;
  font-size: 12px;
  margin-bottom: 8px;
}

.dev-action {
  background: transparent;
  color: #cbd5e1;
  border-color: #46586e;
  display: block;
  width: 100%;
  margin-top: 6px;
}

.dev-action:hover:not(:disabled) {
  background: #1a2432;
}

.dev-empty {
  color: #55677f;
  font-size: 11px;
  margin: 0;
}

.log-area {
  height: 220px;
  overflow-y: auto;
  background: #10161f;
  color: #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-warn {
  color: #fbbf24;
}

.log-error {
  color: #f87171;
}

/* =============================================================================
   접근성·반응형
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  .chat-body.watermarked {
    animation: none;
  }

  .file-msg .file-ttl.urgent {
    animation: none;
  }

  .secure-strip .dot {
    animation: none;
  }

  .spinner {
    animation-duration: 2.4s;
  }

  .toast {
    transition: none;
  }

  .chat-body.dissolving {
    transition: none;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 8px;
  }

  .app-frame {
    height: calc(100vh - 16px);
    min-height: 480px;
  }

  .dev-panel {
    right: 8px;
    width: calc(100vw - 16px);
  }
}
