/* =============================================
   VOD AIGC Chat — Main Stylesheet
   ============================================= */

/* --- Variables --- */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1e1e1e;
  --surface3: #252525;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --text: #e8e8e8;
  --text-dim: #888888;
  --text-muted: #555555;
  --accent: #4a5d7e;
  --accent-light: #6b82a3;
  --accent-deep: #3a4a66;
  --accent-glow: 74, 93, 126;
  --green: #4ade80;
  --orange: #fb923c;
  --red: #f87171;
  --cyan: #22d3ee;
  --purple: #c084fc;
  --yellow: #facc15;
  --radius: 12px;
  --radius-sm: 8px;
  /* 전역 UI 스케일 — 100% 브라우저 줌에서 UI가 과하게 커 보이던 문제 보정.
     0.85 = 사용자가 브라우저 85% 줌으로 보던 것과 동일한 크기.
     조절이 필요하면 이 값만 바꾸면 됨(예: 0.9 = 조금 더 크게). */
  --ui-scale: 0.85;
}

/* --- Reset --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 전역 축소: 브라우저 줌과 동일하게 루트를 축소한다.
   (현대 브라우저 spec 기준 zoom 은 vh 를 스케일하지 않으므로,
    화면을 꽉 채워야 하는 100vh 요소는 1/scale 로 보정한다 — body/.debug-panel)
   배경색을 루트에도 깔아 보정 오차 시 흰 띠가 보이지 않게 한다. */
html { zoom: var(--ui-scale); background: var(--bg); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: calc(100vh / var(--ui-scale));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  row-gap: 8px;
}

.header-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.header-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.header-badge {
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  margin-left: auto;
}

/* --- Mode Switcher --- */
.mode-switcher {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 3px;
  margin-left: 12px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-tab-icon {
  flex-shrink: 0;
  opacity: 0.85;
}
.mode-tab.active .mode-tab-icon { opacity: 1; }

.mode-tab:hover { color: var(--text); background: var(--surface3); }
.mode-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--accent-glow), 0.3);
}

/* --- Layout ---
   사이드바 폭은 viewport 에 따라 단계적으로 줄인다. 100% zoom 기준으로
   ≥1600px 화면에선 340px, 1280~1599px 에선 300px, 1101~1279px 에선 280px.
   고정 340px 이면 1440px 노트북에서 메인 영역이 좁아져 Battle 셀이 잘림. */
.main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 0;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Form Fields --- */
.field-group { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-input,
.field-select,
.field-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--accent);
}

.field-textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.field-select { cursor: pointer; }

/* --- Token Input --- */
.token-input-wrap { position: relative; }
.token-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px;
}

/* --- Temperature Slider --- */
.temp-row { display: flex; align-items: center; gap: 10px; }
.temp-slider {
  flex: 1; -webkit-appearance: none; height: 4px;
  background: var(--border); border-radius: 2px; outline: none;
}
.temp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
}
.temp-value { font-size: 13px; color: var(--accent-light); font-weight: 600; min-width: 30px; text-align: right; }

/* --- Section Divider & Title --- */
.section-divider { height: 1px; background: var(--border); margin: 4px 0; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: none;
  letter-spacing: 0.3px;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Option Pills --- */
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover { border-color: var(--border-hover); color: var(--text); }
.pill.active {
  background: rgba(var(--accent-glow), 0.15);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* --- Duration Chips --- */
.duration-chips { display: flex; gap: 8px; }

.duration-chip {
  flex: 1; padding: 10px; text-align: center;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 700;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; transition: all 0.2s;
}

.duration-chip small {
  display: block; font-size: 10px; font-weight: 400;
  margin-top: 2px; color: var(--text-muted);
}

.duration-chip:hover { border-color: var(--border-hover); color: var(--text); }
.duration-chip.active {
  background: rgba(var(--accent-glow), 0.15);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* --- Upload Area --- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px; text-align: center;
  cursor: pointer; transition: all 0.2s;
  background: var(--surface2);
}

.upload-area:hover { border-color: var(--accent); background: rgba(var(--accent-glow), 0.05); }
.upload-icon { font-size: 28px; margin-bottom: 6px; opacity: 0.5; }
.upload-text { font-size: 12px; color: var(--text-dim); }
.upload-hint { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Multi-upload */
.upload-multi {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.upload-multi-item {
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; background: var(--surface2);
  font-size: 11px; color: var(--text-dim);
}

.upload-multi-item:hover { border-color: var(--accent); background: rgba(var(--accent-glow), 0.05); }
.upload-multi-item .add-icon { font-size: 20px; opacity: 0.4; }

/* --- Collapsible --- */
.collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 6px 0;
}
.collapsible-header .arrow { font-size: 10px; color: var(--text-dim); transition: transform 0.2s; }
.collapsible-header.open .arrow { transform: rotate(90deg); }
.collapsible-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.collapsible-body.open { max-height: 200px; }

/* --- Checkbox --- */
.check-option {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer; padding: 4px 0;
}
.check-option input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* --- Feature Badge --- */
.feature-badge {
  font-size: 9px; padding: 2px 6px; border-radius: 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-left: auto;
}
.feature-badge.new { background: rgba(74, 222, 128, 0.15); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.3); }
.feature-badge.optional { background: rgba(136, 136, 136, 0.1); color: var(--text-dim); border: 1px solid var(--border); }

/* --- Cumulative Stats Panel --- */
.cumulative-stats {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stat-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-row-label { font-size: 12px; color: var(--text-dim); }
.stat-row-value { font-size: 13px; font-weight: 700; }
.stat-row-value.green  { color: var(--green); }
.stat-row-value.orange { color: var(--orange); }
.stat-row-value.accent { color: var(--accent-light); }
.stat-row-value.cyan   { color: var(--cyan); }
.stat-row-value.purple { color: var(--purple); }

.reload-btn, .reset-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 12px; border-radius: 4px; padding: 1px 6px; cursor: pointer;
  margin-left: 4px; transition: color 0.2s, border-color 0.2s; vertical-align: middle;
}
.reload-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.reset-btn:hover { color: var(--red); border-color: var(--red); }

/* --- Hidden panels --- */
.panel-hidden { display: none !important; }

/* =============================================
   Content Area (right side)
   ============================================= */

.content-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* --- LLM Chat Mode --- */
.chat-area {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.chat-area.active { display: flex; }

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

.msg {
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-user { align-self: flex-end; }
.msg-user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 12px 16px;
}

.msg-assistant { align-self: flex-start; }
.msg-assistant .msg-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  padding: 16px;
}

.msg-bubble {
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

/* --- Token Stats Card --- */
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.stat-item { text-align: center; }

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-value.green  { color: var(--green); }
.stat-value.orange { color: var(--orange); }

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Message Meta --- */
.msg-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  gap: 12px;
}

/* --- Token Detail Tags --- */
.stats-detail {
  display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap;
}

.detail-tag {
  font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 6px; display: inline-flex; align-items: center; gap: 4px;
}

.detail-tag.cached {
  background: rgba(38, 198, 218, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(38, 198, 218, 0.3);
}

.detail-tag.reasoning {
  background: rgba(171, 71, 188, 0.12);
  color: var(--purple);
  border: 1px solid rgba(171, 71, 188, 0.3);
}

/* --- Loading Indicator --- */
.loading-dots { display: inline-flex; gap: 4px; padding: 12px 16px; }
.loading-dots span {
  width: 8px; height: 8px; background: var(--text-dim);
  border-radius: 50%; animation: bounce 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);    opacity: 1;   }
}

/* --- Chat Image Attach --- */
.chat-attach-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 18px; width: 46px; height: 46px;
  border-radius: 12px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s;
}
.chat-attach-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.chat-attach-btn.has-file { border-color: var(--green); color: var(--green); }

.chat-attach-preview {
  display: flex; gap: 6px; padding: 4px 24px 0; flex-wrap: wrap;
  background: var(--surface);
}
.chat-attach-preview:empty { display: none; padding: 0; }

.chat-attach-thumb {
  position: relative; width: 56px; height: 56px;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border); flex-shrink: 0;
}
.chat-attach-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-attach-thumb .chat-attach-remove {
  position: absolute; top: -2px; right: -2px;
  background: var(--red); color: #fff; border: none;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 9px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  line-height: 1;
}

.msg-user-images {
  display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap;
}
.msg-user-images img {
  max-width: 200px; max-height: 150px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  object-fit: cover;
}

/* --- Input Bar --- */
.input-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.input-bar textarea {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 46px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.input-bar textarea:focus { border-color: var(--accent); }

.send-btn {
  background: var(--accent); border: none; border-radius: 12px;
  color: #fff; width: 46px; height: 46px; display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  font-size: 20px; transition: background 0.2s, transform 0.1s; flex-shrink: 0;
}
.send-btn:hover    { background: var(--accent-light); }
.send-btn:active   { transform: scale(0.95); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.send-btn.stop-mode { background: var(--red); }
.send-btn.stop-mode:hover { background: #ef5350; }

.stream-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); cursor: pointer; flex-shrink: 0;
}
.stream-toggle input { accent-color: var(--accent); }

.new-chat-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; font-weight: 600;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  flex-shrink: 0; transition: all 0.2s; white-space: nowrap; height: 46px;
  display: flex; align-items: center;
}
.new-chat-btn:hover { border-color: var(--red); color: var(--red); background: rgba(239, 83, 80, 0.08); }

.turn-counter {
  font-size: 11px; color: var(--text-dim); font-weight: 600; flex-shrink: 0;
  padding: 4px 8px; background: var(--surface2); border-radius: 6px; white-space: nowrap;
}

/* --- Empty State --- */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; color: var(--text-dim); gap: 12px;
}
.empty-icon { font-size: 48px; opacity: 0.3; }
.empty-text { font-size: 15px; text-align: center; }

/* --- Error Message --- */
.error-msg {
  background: rgba(239, 83, 80, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
}

/* =============================================
   Generation Mode (Image & Video)
   ============================================= */

.gen-area {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.gen-area.active { display: flex; }

/* Prompt input for generation */
.gen-prompt-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.gen-prompt-bar textarea {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 80px;
  max-height: 160px;
  line-height: 1.5;
}

.gen-prompt-bar textarea:focus { border-color: var(--accent); }

.attach-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 20px; width: 46px; min-height: 46px;
  border-radius: 12px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s;
}
.attach-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.attach-btn.has-file { border-color: var(--green); color: var(--green); }

.gen-attach-preview {
  display: flex; gap: 8px; padding: 0 24px; flex-wrap: wrap;
}
.gen-attach-preview:empty { display: none; }

.attach-thumb {
  position: relative; width: 64px; height: 64px;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border);
}
.attach-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.attach-thumb .attach-remove {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff; border: none;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 10px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}

.generate-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border: none; border-radius: 12px;
  color: #fff; padding: 14px 24px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px rgba(var(--accent-glow), 0.3);
}
.generate-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(var(--accent-glow), 0.4); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.generate-btn.stop-mode {
  background: linear-gradient(135deg, var(--red), #c62828);
  box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3);
  opacity: 1; cursor: pointer;
}
.generate-btn.stop-mode:hover { transform: translateY(-1px); }

/* Result display */
.gen-results {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gen-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; flex-shrink: 0; color: var(--text-dim); gap: 12px;
}

/* Result card */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  animation: fadeIn 0.3s ease;
}

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

.result-card-status { display: flex; align-items: center; gap: 8px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.processing { background: var(--orange); animation: pulse 1.5s infinite; }
.status-dot.success { background: var(--green); }
.status-dot.error { background: var(--red); }

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

.result-card-info {
  font-size: 12px; color: var(--text-dim); display: flex; gap: 12px;
  align-items: center;
}

/* Per-card Stop button (shown only while a request is in flight) */
.card-stop-btn {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: 4px;
}
.card-stop-btn:hover {
  background: var(--red);
  color: #fff;
}

.result-card-body { padding: 16px; }

.result-image {
  width: 100%; max-width: 512px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}

.result-download {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 6px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim);
  font-size: 12px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: all 0.2s;
}
.result-download:hover { border-color: var(--accent); color: var(--accent-light); }

.result-video {
  width: 100%; max-width: 640px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #000;
}

.result-audio {
  width: 100%; max-width: 520px;
  display: block;
  margin-bottom: 4px;
}

/* --- API Guide notice bar (per section, dismissable) --- */
.api-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(var(--accent-glow), 0.10);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  margin: 14px 16px 2px 16px;
  flex-shrink: 0;
}
.api-notice-text {
  font-size: 12.5px;
  color: var(--text-dim);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.api-notice-text a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
}
.api-notice-text a:hover { text-decoration: underline; }
.api-notice-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.2s;
}
.api-notice-close:hover { color: var(--text); background: var(--surface3); }

/* --- Sidebar engine note (per-model hint under selects/pills) --- */
.engine-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.45;
}

.result-prompt {
  font-size: 13px; color: var(--text-dim); margin-top: 12px;
  padding: 10px 12px; background: var(--surface2);
  border-radius: var(--radius-sm); line-height: 1.5;
}

.info-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 4px; background: var(--surface2);
  color: var(--text-dim); border: 1px solid var(--border);
}
.info-tag.engine { color: var(--accent-light); border-color: rgba(var(--accent-glow), 0.3); }

/* =============================================
   Debug Panel
   ============================================= */

.debug-toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 14px; font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  padding: 6px 12px; border-radius: 8px;
  cursor: pointer; margin-left: 8px; transition: all 0.2s; flex-shrink: 0;
}
.debug-toggle-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.debug-toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.debug-panel {
  position: fixed; top: 0; right: 0;
  width: 480px; height: calc(100vh / var(--ui-scale));
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}

.debug-panel.open { transform: translateX(0); }

.debug-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.debug-panel-title { font-size: 15px; font-weight: 700; color: var(--text); }

.debug-panel-close {
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 14px;
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.debug-panel-close:hover { border-color: var(--red); color: var(--red); }

.debug-panel-content {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 16px;
}

.debug-section { display: flex; flex-direction: column; gap: 8px; }

.debug-section-label {
  font-size: 12px; font-weight: 700;
  color: var(--accent-light); text-transform: uppercase; letter-spacing: 0.5px;
}

.debug-json {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px; line-height: 1.6; color: var(--text);
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  max-height: 45vh; overflow-y: auto; margin: 0;
}

.debug-placeholder {
  color: var(--text-dim); font-style: italic; font-family: inherit;
}

/* JSON syntax highlighting */
.json-key     { color: #82aaff; }
.json-string  { color: #c3e88d; }
.json-number  { color: #f78c6c; }
.json-boolean { color: #c792ea; }
.json-null    { color: #ef5350; }
/* Emphasised keys — engine / endpoint / status / error */
.json-engine        { color: #ffd166; font-weight: 700; }
.json-engine-key    { color: #ffd166; font-weight: 700; letter-spacing: 0.3px; }
.json-endpoint      { color: #4dd0e1; font-weight: 600; }
.json-status-ok     { color: #5cf2c0; font-weight: 600; }
.json-status-err    { color: #ff6b6b; font-weight: 700; }
.json-error-key     { color: #ff6b6b; font-weight: 700; }
.json-error-string  { color: #ff8a8a; }

/* === Debug panel — multi-mode tabs + entry list === */
.debug-mode-tabs {
  display: flex; gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow-x: auto;
}
.debug-mode-tab {
  background: transparent;
  border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 7px 10px;
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  transition: all 0.15s;
}
.debug-mode-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.debug-mode-tab.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  border-bottom-color: var(--bg);
  margin-bottom: -1px;
}
.debug-mode-tab .dbg-count {
  display: inline-block; min-width: 18px; padding: 1px 6px;
  font-size: 10px; font-weight: 700;
  background: rgba(130,170,255,0.18);
  color: #82aaff;
  border-radius: 9px; text-align: center;
}
.debug-mode-tab.active .dbg-count {
  background: rgba(255,209,102,0.20);
  color: #ffd166;
}

.debug-panel-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 4px; flex-shrink: 0; gap: 12px;
}
.debug-panel-hint {
  font-size: 11px; color: var(--text-dim); font-style: italic;
}
.debug-clear-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.debug-clear-btn:hover { color: var(--red); border-color: var(--red); }

.debug-empty { padding: 12px 20px; }
.debug-entries {
  display: flex; flex-direction: column; gap: 10px;
  padding: 0 20px 20px;
}

.debug-entry {
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-dim);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.debug-entry.status-ok      { border-left-color: #5cf2c0; }
.debug-entry.status-error   { border-left-color: #ff6b6b; }
.debug-entry.status-pending { border-left-color: #ffd166; }

.debug-entry-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.debug-entry-header:hover { background: rgba(255,255,255,0.025); }
.debug-entry-engine {
  font-size: 12px; font-weight: 700;
  color: #ffd166; letter-spacing: 0.3px;
}
.debug-entry-endpoint {
  font-size: 11px; color: #4dd0e1;
  font-family: 'SF Mono','Fira Code','Consolas',monospace;
}
.debug-entry-time { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.debug-entry-status {
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 9px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.debug-entry-status.ok      { color: #5cf2c0; background: rgba(92,242,192,0.12); }
.debug-entry-status.error   { color: #ff6b6b; background: rgba(255,107,107,0.12); }
.debug-entry-status.pending { color: #ffd166; background: rgba(255,209,102,0.12); }
.debug-entry-caret {
  font-size: 10px; color: var(--text-dim);
  transition: transform 0.15s;
}
.debug-entry.collapsed .debug-entry-caret { transform: rotate(-90deg); }
.debug-entry-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
}
.debug-entry.collapsed .debug-entry-body { display: none; }
.debug-entry .debug-section-label {
  font-size: 10px; padding-top: 8px;
}
.debug-entry .debug-json {
  max-height: 28vh;
}

/* === Battle dummy placeholder — uses monkey image when result fails === */
.battle-cell-placeholder.dummy-monkey {
  position: relative;
  background: #c33b32;       /* matches the monkey image's red background */
  background-image: url("../icons/dummy-monkey.png");
  background-size: cover;
  background-position: center;
  animation: none;
  overflow: hidden;
}
.battle-cell-placeholder.dummy-monkey::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.05) 0%,
    rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}
.battle-cell-placeholder.dummy-monkey .ph-engine,
.battle-cell-placeholder.dummy-monkey .ph-note,
.battle-cell-placeholder.dummy-monkey .ph-icon {
  position: relative; z-index: 1; opacity: 1; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.battle-cell-placeholder.dummy-monkey .ph-icon {
  font-size: 16px;
  background: rgba(0,0,0,0.45);
  padding: 3px 9px; border-radius: 9px;
  letter-spacing: 0.5px; font-weight: 700; text-transform: uppercase;
  font-size: 10px;
}
.battle-cell-placeholder.dummy-monkey .ph-engine {
  font-weight: 800; font-size: 14px; letter-spacing: 0.4px;
}
.battle-cell-placeholder.dummy-monkey .ph-note {
  font-size: 10px; opacity: 0.95;
  background: rgba(0,0,0,0.35); padding: 2px 8px; border-radius: 8px;
  max-width: 90%; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* =============================================
   Scrollbar
   ============================================= */

::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* =============================================
   Responsive
   ============================================= */

/* 사이드바 폭 단계적 축소 — viewport 이 좁아질수록 메인 영역에 더 많은
   픽셀을 양보. 1600px 이상에선 340px 회복. */
@media (min-width: 1600px) {
  .main { grid-template-columns: 340px 1fr; }
  .sidebar { padding: 20px; }
}
@media (max-width: 1279px) {
  .main { grid-template-columns: 280px 1fr; }
  .sidebar { padding: 16px 14px; gap: 14px; }
}

@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
  .mode-switcher { margin-left: 8px; }
  .mode-tab { padding: 6px 12px; font-size: 12px; }
  .debug-panel { width: 100% !important; }
}

/* === Sidebar field spacing — System Prompt / Temperature === */
.field-group-spaced { margin-top: 18px; }
.field-group-spaced + .field-group-spaced { margin-top: 14px; }

/* === Inline info icon (i) with hover tooltip === */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim, #888);
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  cursor: help;
  position: relative;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.12);
}
.info-icon:hover, .info-icon:focus {
  background: rgba(99,179,237,0.12);
  color: #63b3ed;
  border-color: rgba(99,179,237,0.4);
  outline: none;
}
.info-icon .info-tooltip {
  visibility: hidden;
  opacity: 0;
  /* fixed로 띄워 사이드바 overflow 경계를 빠져나감 (채팅창 영역 침범 OK) */
  position: fixed;
  left: 0;
  top: 0;
  width: max-content;
  max-width: min(360px, calc(100vw - 40px));
  padding: 10px 12px;
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  /* 다른 요소 위로 — 디버그 패널(z:1000)보다 낮게 유지 */
  z-index: 900;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 12px;
  line-height: 1.5;
  font-style: normal;
  font-weight: 400;
  white-space: normal;
  text-align: left;
}
.info-icon:hover .info-tooltip,
.info-icon:focus .info-tooltip {
  visibility: visible;
  opacity: 1;
}

/* === Text Gen 상단 공지 배너 === */
.text-gen-notice {
  margin: 8px 16px 0 16px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(99,179,237,0.10) 0%, rgba(159,122,234,0.10) 100%);
  border: 1px solid rgba(99,179,237,0.25);
  border-radius: 8px;
  color: #cbd5e0;
  font-size: 13px;
  line-height: 1.5;
}
.text-gen-notice a {
  color: #63b3ed;
  text-decoration: none;
  border-bottom: 1px dotted rgba(99,179,237,0.5);
}
.text-gen-notice a:hover { color: #90cdf4; border-bottom-color: #90cdf4; }

/* === Battle 모드 헤더 + 격자 === */
.battle-header-bar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 18px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
}
.battle-title { font-size: 16px; font-weight: 600; color: #e2e8f0; }
.battle-desc  { font-size: 12px; color: var(--text-dim, #888); }

.battle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px;
  align-content: start;
}
.battle-cell {
  display: flex;
  flex-direction: column;
  background: #1f2125;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  overflow: hidden;
  min-height: 240px;
  transition: border-color 0.2s;
}
.battle-cell.complete { border-color: rgba(72,187,120,0.4); }
.battle-cell.error    { border-color: rgba(229,62,62,0.4); }
.battle-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 12px;
}
.battle-cell-engine { font-weight: 500; color: #cbd5e0; font-size: 11px; letter-spacing: 0.2px; }
.battle-cell-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #a0aec0;
}
.battle-cell-status.running   { background: rgba(99,179,237,0.15); color: #63b3ed; }
.battle-cell-status.complete  { background: rgba(72,187,120,0.15); color: #48bb78; }
.battle-cell-status.error     { background: rgba(229,62,62,0.15);  color: #fc8181; }
.battle-cell-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
  min-height: 180px;
}
.battle-cell-body img,
.battle-cell-body video {
  max-width: 100%;
  max-height: 320px;
  border-radius: 6px;
  object-fit: contain;
}
.battle-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim, #888);
  font-size: 12px;
  width: 100%;
  height: 100%;
  margin: auto;
  text-align: center;
}
.battle-spinner::before {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid rgba(99,179,237,0.2);
  border-top-color: #63b3ed;
  border-radius: 50%;
  animation: battle-spin 0.9s linear infinite;
}
@keyframes battle-spin {
  to { transform: rotate(360deg); }
}
.battle-cell-error {
  color: #fc8181;
  font-size: 11px;
  /* 헤더가 absolute top:0 으로 떠 있어 본문 텍스트와 겹쳐 보였음 → 상단 패딩으로 헤더만큼 밀어냄 */
  padding: 40px 14px 14px;
  text-align: center;
  line-height: 1.45;
  opacity: 0.85;
}
.battle-cell-elapsed {
  font-size: 11px;
  color: var(--text-dim, #888);
}

/* === Mode tab 그룹 분리 (Battle 메뉴 앞 공백) === */
.mode-tab-divider {
  display: none;   /* 더 이상 사용 안 함 — 두 그룹 사이는 공백 gap 으로 처리 */
}
/* 두 mode-switcher 박스 사이 간격 */
.mode-switcher + .mode-switcher {
  margin-left: 14px;
}
.mode-tab-battle {
  background: rgba(99,179,237,0.06);
}
.mode-tab-battle.active {
  background: rgba(99,179,237,0.18);
}

/* API Guide — mode-tab 형식이지만 따뜻한 amber 톤으로 시각적 차별화 */
.mode-tab-api {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  background: rgba(217, 167, 92, 0.10);    /* warm amber tint */
  color: #d9a75c;
  letter-spacing: 0.2px;
}
.mode-tab-api:hover {
  background: rgba(217, 167, 92, 0.18);
  color: #e8b974;
}

/* === 헤더 — API Guide 대메뉴 링크 (구버전 — mode-switcher 안으로 이동되어 무력화) === */
.header-api-guide { display: none; }

/* === Battle 설명/제목 폰트 키움 + 헤더 정돈 === */
.battle-header-bar {
  padding: 14px 22px 12px;
  gap: 18px;
}
.battle-title { font-size: 18px; font-weight: 600; }
.battle-desc  { font-size: 14px; line-height: 1.5; }

/* === Battle 격자 — 사이즈별 고정 칼럼 수 === */
/* Image: 3 × 3 = 9 cells */
.battle-grid-image {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  padding: 14px;
  align-content: start;
  align-items: stretch;
  width: 100%;
}
/* Video: 4 × 3 = 12 cells */
.battle-grid-video {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  padding: 14px;
  align-content: start;
  align-items: stretch;
  width: 100%;
}
/* 좁은 화면 fallback ─ 1440px Macbook 등 일반 노트북에서 100% zoom 시
   Battle 셀이 잘리지 않도록 미디어쿼리를 단계적으로 앞당김.
   - ≥1600px : 4×3 (image 3×3, video 4×3)  — 와이드 모니터
   - 1280~1599px: 3×3 / 3 row              — 일반 노트북
   - 1100~1279px: 2×3 / 3 row               — 좁은 노트북
   -  768~1099px: 1컬럼                      — 태블릿
   -  ≤767px   : 1컬럼                       — 모바일 */
@media (max-width: 1599px) {
  .battle-grid-video { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .battle-grid-image { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1279px) {
  .battle-grid-video { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .battle-grid-image { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1099px) {
  .battle-grid-video { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-grid-image { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .battle-grid-video,
  .battle-grid-image { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}

/* Battle 모드일 때 빈 상태(empty)는 격자가 아니라 한 줄짜리 안내로 — 가운데 정렬 */
.battle-grid > .gen-empty {
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 120px;
  padding: 32px 16px;
  font-size: 14px;
}

/* battle-cell 사이즈 자동 — 격자 칸을 꽉 채움 */
.battle-cell {
  min-height: 0;
  height: 100%;
}
.battle-cell-body {
  min-height: 0;
  flex: 1;
}
.battle-cell-body img,
.battle-cell-body video {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

/* === Battle 모드일 때 메인 영역을 더 넓게 — 사이드바를 살짝 줄임 === */
body.battle-mode .sidebar { display: none; }
body.battle-mode .main { grid-template-columns: 1fr; }

/* === Battle: 전체 재생 버튼 === */
.battle-header-bar { position: relative; }
.battle-action-btn {
  margin-left: auto;
  padding: 6px 14px;
  background: rgba(99,179,237,0.12);
  border: 1px solid rgba(99,179,237,0.35);
  color: #63b3ed;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.battle-action-btn:hover {
  background: rgba(99,179,237,0.22);
  border-color: rgba(99,179,237,0.55);
}
.battle-action-btn:active { transform: translateY(1px); }

/* === Battle 이미지 클릭 가능 === */
.battle-cell-body img.battle-img-clickable {
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.battle-cell-body img.battle-img-clickable:hover { opacity: 0.88; }

/* === Battle 헤더 호버 시 살짝 강조 (프롬프트 툴팁 hint) === */
.battle-cell-header { cursor: help; }

/* === Sidebar 가로 스크롤 제거 — info-tooltip 등 자식 오버플로 방어 === */
.sidebar { overflow-x: hidden; }

/* === 헤더 뱃지 톤다운 (문의사항 안내) === */
.header-badge {
  font-size: 9px;
  background: transparent;
  color: #6a6f76;
  border: none;
  padding: 2px 6px;
  letter-spacing: 0.1px;
  font-weight: 400;
  opacity: 0.45;
  transition: opacity 0.2s;
}
.header-badge:hover {
  opacity: 0.85;
}

/* === Battle 헤더 — 'API Guide' 링크 버튼 === */
.battle-action-btn.battle-action-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  margin-left: 0;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
  color: #a0aec0;
}
.battle-action-btn.battle-action-link:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.22);
  color: #cbd5e0;
}

/* === 이미지 배틀 — 라이트박스 모달 (다운로드 대신) === */
.img-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 32px; cursor: zoom-out;
  animation: imgmodal-fade 0.18s ease-out;
}
.img-modal-overlay img {
  max-width: 92vw; max-height: 92vh;
  border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  cursor: default;
  user-select: none;
}
.img-modal-overlay .img-modal-close {
  position: absolute; top: 18px; right: 22px;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.18);
  color: #fff; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.img-modal-overlay .img-modal-close:hover {
  background: rgba(255,255,255,0.20);
}
@keyframes imgmodal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* === Battle 셀 — 진행중 락(엔진 라벨에 lock 점) === */
.battle-cell.running .battle-cell-engine::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: #63b3ed;
  border-radius: 50%;
  margin-right: 6px;
  animation: battle-running-pulse 1.2s ease-in-out infinite;
  vertical-align: 1px;
}
@keyframes battle-running-pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50%      { opacity: 1.0;  transform: scale(1.3); }
}

/* === Battle 셀 — placeholder (에러/빈 URL일 때 더미 카드) === */
.battle-cell.placeholder {
  border-color: rgba(255,255,255,0.10);
}
.battle-cell-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  background:
    linear-gradient(135deg,
      rgba(74,93,126,0.15) 0%,
      rgba(58,74,102,0.20) 50%,
      rgba(74,93,126,0.15) 100%);
  background-size: 200% 200%;
  animation: placeholder-shift 6s ease-in-out infinite;
  color: #6b7280;
  font-size: 11px;
  text-align: center;
  padding: 12px;
}
.battle-cell-placeholder .ph-engine {
  font-size: 13px; font-weight: 600; color: #a0aec0; opacity: 0.55;
  letter-spacing: 0.4px;
}
.battle-cell-placeholder .ph-note {
  font-size: 10px; color: #7c8590; opacity: 0.7;
}
.battle-cell-placeholder .ph-icon {
  font-size: 22px; opacity: 0.35;
}
@keyframes placeholder-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* === 모든 프롬프트 입력창 — 한 줄 시작 + 10줄까지 확장 + 이후 스크롤 ===
   line-height 1.5 × font-size 14px = 21px,
   padding 12+12 = 24, border 2 → 1줄 ≈ 47px, 10줄 ≈ 47 + 9*21 ≈ 236px.
   JS 의 autoResize() 와 함께 동작. */
.input-bar textarea,
.gen-prompt-bar textarea {
  line-height: 1.5;
  min-height: 46px;        /* 한 줄 높이 — attach/send 버튼(46px)과 정렬 */
  max-height: 236px;       /* 약 10줄 */
  overflow-y: auto;
  resize: none;
}

/* === Battle 셀 헤더 — 슬림하게 (그림 영역 확보) === */
.battle-cell-header {
  padding: 3px 10px;          /* 8 12 → 3 10 */
  font-size: 10px;            /* 12 → 10 */
  line-height: 1.4;
  gap: 8px;
  min-height: 22px;
  /* 엔진명/상태가 좁은 셀에서 두 줄로 떨어지지 않도록 한 줄로 강제 */
  flex-wrap: nowrap;
}
.battle-cell-engine {
  font-size: 10px;
  letter-spacing: 0.15px;
  /* 한 줄로 고정 + 셀 폭에 맞춰 줄임표 처리 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}
.battle-cell-status {
  font-size: 10px;
  padding: 0;                  /* 둥근 배경 제거 */
  background: transparent !important;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
/* 진행중 펄스 점 — 좀 더 작게 */
.battle-cell.running .battle-cell-engine::before {
  width: 5px; height: 5px; margin-right: 5px;
}

/* === 이미지 배틀 셀 — 9개 한 줄 정사각형 ===
   사용자 요청: 이미지가 너무 커서 세로 스크롤이 길어짐 → 9개를 가로 한 줄
   정사각형 썸네일로 깔고, 클릭하면 라이트박스에서 원본 확대. */
.battle-grid-image .battle-round-grid {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-auto-rows: auto;
  /* 너무 좁은 화면에선 셀이 비정상적으로 작아지지 않도록 최소 폭 보장 +
     가로 스크롤로 9개 일렬 유지. */
  overflow-x: auto;
  overflow-y: hidden;
}
.battle-grid-image .battle-cell {
  aspect-ratio: 1 / 1;
  min-height: 0;
  height: auto;
  /* 데스크탑에서도 9개가 너무 좁아지면 최소 110px로 가로 스크롤이 켜진다. */
  min-width: 110px;
}
.battle-grid-image .battle-cell-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.battle-grid-image .battle-cell-body img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: cover;          /* 정사각형 썸네일 — contain 시 위아래 공백이 또 생김 */
  display: block;
  border-radius: 0;
}
/* 라운드별 grid에 가로 스크롤 영역 시각화용 다크 스크롤바 */
.battle-grid-image .battle-round-grid::-webkit-scrollbar { height: 8px; }
.battle-grid-image .battle-round-grid::-webkit-scrollbar-track { background: transparent; }
.battle-grid-image .battle-round-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 4px;
}
.battle-grid-image .battle-round-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.20);
}
  align-items: center;
  justify-content: center;
}
.battle-grid-image .battle-cell-body img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;       /* 비율 유지하며 셀 안에 끼워 맞춤 */
  display: block;
  border-radius: 0;
  background: #0e1014;       /* 비율 다른 이미지 양옆 검정 padding */
}

/* 좁은 화면에서도 이미지 배틀은 9 컬럼 유지 — 가로 스크롤로 한 줄 보존.
   (비디오는 셀이 더 커서 줄바꿈이 자연스럽지만, 이미지는 사용자가 "9개 일렬"을
   명시적으로 요청했으므로 어떤 폭에서도 한 줄 유지가 의도된 동작.) */
@media (max-width: 1400px) {
  .battle-grid-image .battle-round-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
}
@media (max-width: 900px) {
  .battle-grid-image .battle-round-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
}
@media (max-width: 540px) {
  .battle-grid-image .battle-round-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
}

/* === 비디오 배틀 셀 — 자유롭게 흘러내리며 부모(.battle-grid)가 스크롤 ===
   이전엔 round 가 viewport 100% 를 잡아 fit-to-screen 강제했으나, 라운드가
   여러 개일 때 스크롤이 어색해서 자연 흘러내림 + .battle-grid 스크롤로
   바꿈 (override 는 2836줄). */
.battle-grid-video .battle-round {
  /* 원래 flex 컨테이너로 viewport 점유했으나 더 이상 사용 안 함 (2836에서 override) */
}
.battle-grid-video .battle-round-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  gap: 8px;
}
.battle-grid-video .battle-cell {
  /* aspect-ratio 제거 — 그리드가 셀 높이를 결정.
     min/max-height를 명시적으로 덮어 base 룰의 min-height:240px가
     영상 결과 도착 후 셀을 부풀리는 것을 차단. */
  min-height: 0 !important;
  max-height: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}
.battle-grid-video .battle-cell-body {
  /* 핵심: position: relative + 자식 video/img는 absolute로 inset:0 강제 →
     video의 intrinsic 크기가 셀을 부풀리지 못함 */
  position: relative;
  flex: 1 1 0;
  min-height: 0 !important;     /* base .battle-cell-body의 min-height:180px override */
  max-height: 100%;
  overflow: hidden;
  padding: 0;
  display: block;
  background: #0e1014;
}
.battle-grid-video .battle-cell-body video,
.battle-grid-video .battle-cell-body img {
  position: absolute;
  inset: 0;                     /* top/right/bottom/left = 0 */
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  object-fit: cover;            /* 영상도 셀에 꽉 차게 — contain 시 0~수 px의 잔여 띠가 생기는 것 방지 */
  display: block;
  background: #0e1014;
}
/* placeholder / spinner도 셀을 키우지 못하도록 absolute fill */
.battle-grid-video .battle-cell-body > .battle-spinner,
.battle-grid-video .battle-cell-body > .battle-cell-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}
@media (max-width: 1100px) {
  .battle-grid-video .battle-round-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .battle-grid-video .battle-round-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .battle-grid-video .battle-round-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); grid-auto-rows: minmax(120px, 1fr); grid-template-rows: none; }
}

/* 비디오 배틀 헤더는 정보 밀도를 살짝 높여 그리드에 더 많은 세로공간 양보 */
/* === Battle 헤더 — Image/Video 양쪽 동일 톤 (사용자 요청: 통일) === */
#content-image-battle .battle-header-bar,
#content-video-battle .battle-header-bar { padding: 10px 18px 8px; gap: 14px; }
#content-image-battle .battle-title,
#content-video-battle .battle-title { font-size: 14px; font-weight: 600; color: #e2e8f0; }
#content-image-battle .battle-desc,
#content-video-battle .battle-desc  { font-size: 12px; line-height: 1.4; font-weight: 400; color: var(--text-dim, #888); }
#content-video-battle .battle-round-head { margin-bottom: 6px; font-size: 11px; }
#content-video-battle .battle-round-prompt { font-size: 12px; }
#content-video-battle .gen-attach-preview { padding: 4px 18px; }
#content-video-battle .gen-attach-preview .attach-thumb { width: 44px; height: 44px; }

/* 라운드별 "▶ Play All" 버튼 — 헤더 우측에 작게 */
.battle-round-head .round-playall {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: #cbd5e0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.battle-round-head .round-playall:hover {
  border-color: rgba(99,179,237,0.6);
  color: #63b3ed;
  background: rgba(99,179,237,0.08);
}
.battle-round-head .round-playall.is-playing {
  border-color: rgba(72,187,120,0.6);
  color: #48bb78;
  background: rgba(72,187,120,0.10);
}
.battle-round-head .round-playall:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* === Battle 결과 영역 — 라운드 단위 스크롤 컨테이너 ===
   부모(.gen-area)는 flex column. 형제: header / picker / [battle-grid] /
   attach-preview / prompt-bar.  battle-grid 가 남은 세로 공간 전부를
   가져가고 그 안에서 자유 스크롤하도록 flex:1 + min-height:0.  이게
   빠지면 자식들이 자연 높이로 펴지면서 prompt-bar 와 겹치거나 마지막
   행이 viewport 밖으로 나가 스크롤로도 못 본다. */
.battle-grid {
  /* 기존 grid 스타일은 .battle-round-grid 내부에서만 사용 */
  display: block !important;
  grid-template-columns: none !important;
  padding: 0;
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
/* battle-grid 자체에는 더 이상 격자 적용 X — round 내부 grid가 격자 담당 */

/* 라운드 그룹 */
.battle-round {
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 12px 14px 16px;
}
.battle-round:last-child {
  border-bottom: none;
  /* 마지막 라운드는 prompt-bar 위에 여유를 두어 마지막 셀이 잘리지 않게 */
  padding-bottom: 32px;
}

.battle-round-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.battle-round-time {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #6b7280;
  flex-shrink: 0;
}
.battle-round-engines {
  font-size: 11px;
  color: #6b7280;
  flex-shrink: 0;
}
.battle-round-prompt {
  font-size: 13px;
  color: #cbd5e0;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.1px;
}
.battle-round-prompt:hover {
  white-space: normal;
  overflow: visible;
}

/* 라운드 내부 격자 — 기존 battle-grid-image / battle-grid-video 스타일을 적용 */
.battle-round-grid {
  display: grid;
  grid-auto-rows: 1fr;
  gap: 12px;
  align-content: start;
  align-items: stretch;
  width: 100%;
}
.battle-grid-image .battle-round-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
.battle-grid-video .battle-round-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .battle-grid-video .battle-round-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .battle-grid-image .battle-round-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
}
@media (max-width: 768px) {
  .battle-grid-video .battle-round-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .battle-grid-image .battle-round-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
}

/* 비디오 배틀 미리보기 — controls 숨김 (재생/진행바 X) */
.battle-grid-video .battle-cell-body video {
  pointer-events: none;        /* 셀별 클릭으론 제어 안 함 */
}
.battle-grid-video .battle-cell-body video::-webkit-media-controls,
.battle-grid-video .battle-cell-body video::-webkit-media-controls-enclosure,
.battle-grid-video .battle-cell-body video::-webkit-media-controls-panel {
  display: none !important;
  -webkit-appearance: none;
}
/* 셀 자체에 더블클릭 fullscreen 가능하다는 hint */
.battle-grid-video .battle-cell { cursor: zoom-in; }
.battle-grid-video .battle-cell.running,
.battle-grid-video .battle-cell.error { cursor: default; }

/* battle-grid 스크롤바 다크 톤 */
.battle-grid::-webkit-scrollbar { width: 8px; }
.battle-grid::-webkit-scrollbar-track { background: transparent; }
.battle-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 4px;
}
.battle-grid::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

/* battle-grid 안의 빈 상태 안내는 가운데로 (라운드가 아니라 grid 직속일 때) */
.battle-grid > .gen-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 120px;
  padding: 32px 16px;
  font-size: 14px;
}

/* ============================================================
 *  Right-click context menu (delete history items)
 * ============================================================ */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: #1f2125;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  font-size: 13px;
  user-select: none;
  font-family: inherit;
}
.ctx-menu-item {
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  color: #cbd5e0;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.ctx-menu-item:hover {
  background: rgba(255,255,255,0.06);
  color: #ffffff;
}
.ctx-menu-item.danger { color: #fc8181; }
.ctx-menu-item.danger:hover {
  background: rgba(229,62,62,0.15);
  color: #ff6b6b;
}

/* Subtle hint that an item is right-clickable for deletion */
.msg, .result-card, .battle-cell, .battle-round {
  position: relative;
}
.msg:hover { /* extremely subtle — no visible chrome change to avoid distraction */ }

/* =============================================
   Markdown — fenced code blocks in assistant replies
   ============================================= */
/* Inline code: short snippets inside prose */
.msg-assistant .msg-bubble :not(pre) > code {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'SF Mono','Fira Code','JetBrains Mono','Menlo','Consolas',monospace;
  font-size: 0.88em;
  color: #ffd166;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Block code: ```lang … ``` */
.msg-assistant .msg-bubble pre {
  margin: 10px 0;
  background: #0d1117;
  border: 1px solid #1f2933;
  border-radius: 8px;
  overflow: hidden;        /* corner clipping for header */
}
.msg-assistant .msg-bubble pre.code-block { padding: 0; }
.msg-assistant .msg-bubble pre.code-block > code {
  display: block;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: 'SF Mono','Fira Code','JetBrains Mono','Menlo','Consolas',monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #e6edf3;
  white-space: pre;
  overflow-x: auto;
  -webkit-font-smoothing: antialiased;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #161b22;
  border-bottom: 1px solid #1f2933;
  font-size: 11px;
  user-select: none;
}
.code-block-lang {
  font-family: 'SF Mono','Fira Code','Consolas',monospace;
  color: #7d8590;
  text-transform: lowercase;
  letter-spacing: 0.3px;
}
.code-block-copy {
  background: transparent;
  border: 1px solid #30363d;
  color: #adbac7;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.code-block-copy:hover {
  color: #5cf2c0;
  border-color: #5cf2c0;
  background: rgba(92,242,192,0.06);
}
.code-block-copy.done {
  color: #5cf2c0;
  border-color: #5cf2c0;
  background: rgba(92,242,192,0.12);
}

/* Scrollbar inside the code block — dark, slim */
.msg-assistant .msg-bubble pre.code-block > code::-webkit-scrollbar { height: 8px; }
.msg-assistant .msg-bubble pre.code-block > code::-webkit-scrollbar-track { background: transparent; }
.msg-assistant .msg-bubble pre.code-block > code::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10); border-radius: 4px;
}
.msg-assistant .msg-bubble pre.code-block > code::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}

/* =============================================
   Markdown — tables, blockquotes, lists, headings
   (assistant replies only — user bubbles stay plain)
   ============================================= */

/* Headings inside an assistant reply — modest sizes, no giant H1 takeover */
.msg-assistant .msg-bubble h1,
.msg-assistant .msg-bubble h2,
.msg-assistant .msg-bubble h3,
.msg-assistant .msg-bubble h4,
.msg-assistant .msg-bubble h5,
.msg-assistant .msg-bubble h6 {
  margin: 14px 0 6px;
  line-height: 1.35;
  font-weight: 700;
  color: #f0f6fc;
}
.msg-assistant .msg-bubble h1 { font-size: 1.30em; border-bottom: 1px solid #1f2933; padding-bottom: 4px; }
.msg-assistant .msg-bubble h2 { font-size: 1.18em; border-bottom: 1px solid #1f2933; padding-bottom: 3px; }
.msg-assistant .msg-bubble h3 { font-size: 1.08em; }
.msg-assistant .msg-bubble h4,
.msg-assistant .msg-bubble h5,
.msg-assistant .msg-bubble h6 { font-size: 1em; color: #c9d1d9; }
.msg-assistant .msg-bubble h1:first-child,
.msg-assistant .msg-bubble h2:first-child,
.msg-assistant .msg-bubble h3:first-child { margin-top: 0; }

/* Paragraphs — preserve breathing room without inflating short replies */
.msg-assistant .msg-bubble p {
  margin: 6px 0;
}
.msg-assistant .msg-bubble p:first-child { margin-top: 0; }
.msg-assistant .msg-bubble p:last-child  { margin-bottom: 0; }

/* Lists */
.msg-assistant .msg-bubble ul,
.msg-assistant .msg-bubble ol {
  margin: 6px 0;
  padding-left: 22px;
}
.msg-assistant .msg-bubble ul { list-style: disc outside; }
.msg-assistant .msg-bubble ol { list-style: decimal outside; }
.msg-assistant .msg-bubble li {
  margin: 2px 0;
  line-height: 1.65;
}
.msg-assistant .msg-bubble li::marker {
  color: #7d8590;
}
/* Nested lists — slight tightening + alternate marker for visual hierarchy */
.msg-assistant .msg-bubble li > ul,
.msg-assistant .msg-bubble li > ol {
  margin: 2px 0;
}
.msg-assistant .msg-bubble li > ul { list-style: circle outside; }

/* GFM task list (- [ ] / - [x]) — marked emits <li class="task-list-item"> */
.msg-assistant .msg-bubble li.task-list-item {
  list-style: none;
  margin-left: -18px;
  padding-left: 22px;
  position: relative;
}
.msg-assistant .msg-bubble li.task-list-item > input[type="checkbox"] {
  position: absolute; left: 0; top: 6px;
  accent-color: #5cf2c0;
  pointer-events: none;     /* read-only — server-rendered state */
}

/* Blockquote */
.msg-assistant .msg-bubble blockquote {
  margin: 8px 0;
  padding: 6px 14px;
  border-left: 3px solid #ffd166;
  background: rgba(255, 209, 102, 0.06);
  border-radius: 0 6px 6px 0;
  color: #c9d1d9;
  font-style: italic;
}
.msg-assistant .msg-bubble blockquote > p { margin: 2px 0; }
.msg-assistant .msg-bubble blockquote > p:first-child { margin-top: 0; }
.msg-assistant .msg-bubble blockquote > p:last-child  { margin-bottom: 0; }

/* Horizontal rule */
.msg-assistant .msg-bubble hr {
  border: 0;
  border-top: 1px solid #1f2933;
  margin: 14px 0;
}

/* Links — accent-coloured, with subtle underline on hover */
.msg-assistant .msg-bubble a {
  color: #4dd0e1;
  text-decoration: none;
  border-bottom: 1px dotted rgba(77, 208, 225, 0.4);
  transition: color 0.15s, border-color 0.15s;
}
.msg-assistant .msg-bubble a:hover {
  color: #82eaf7;
  border-bottom-color: #82eaf7;
}

/* Tables — GFM */
.msg-assistant .msg-bubble table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
  background: #0d1117;
  border: 1px solid #1f2933;
  border-radius: 8px;
  overflow: hidden;        /* corner clipping for rounded header */
  width: auto;
  max-width: 100%;
  display: block;
  overflow-x: auto;         /* horizontal scroll on narrow viewports */
}
.msg-assistant .msg-bubble table thead {
  background: #161b22;
}
.msg-assistant .msg-bubble table th,
.msg-assistant .msg-bubble table td {
  padding: 7px 12px;
  border-right: 1px solid #1f2933;
  border-bottom: 1px solid #1f2933;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;       /* will wrap on overflow-x */
}
.msg-assistant .msg-bubble table th {
  font-weight: 700;
  color: #f0f6fc;
  letter-spacing: 0.2px;
}
.msg-assistant .msg-bubble table td { color: #c9d1d9; }
.msg-assistant .msg-bubble table tr:last-child td { border-bottom: none; }
.msg-assistant .msg-bubble table th:last-child,
.msg-assistant .msg-bubble table td:last-child { border-right: none; }
.msg-assistant .msg-bubble table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.015);
}
.msg-assistant .msg-bubble table tbody tr:hover {
  background: rgba(92,242,192,0.05);
}
/* Slim scrollbar for tables that overflow */
.msg-assistant .msg-bubble table::-webkit-scrollbar { height: 8px; }
.msg-assistant .msg-bubble table::-webkit-scrollbar-track { background: transparent; }
.msg-assistant .msg-bubble table::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10); border-radius: 4px;
}
.msg-assistant .msg-bubble table::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}

/* Strong / em — subtle emphasis distinct from code */
.msg-assistant .msg-bubble strong { color: #f0f6fc; font-weight: 700; }
.msg-assistant .msg-bubble em     { color: #c9d1d9; font-style: italic; }
/* GFM ~~strike~~ */
.msg-assistant .msg-bubble del    { color: #7d8590; }

/* Image inside a reply (rare but supported) */
.msg-assistant .msg-bubble img {
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid #1f2933;
  margin: 8px 0;
}

/* === Battle 셀 — Retry 버튼 (실패/empty 시 헤더 우측에 표시) === */
.battle-cell-retry {
  background: rgba(99,179,237,0.12);
  border: 1px solid rgba(99,179,237,0.35);
  color: #93c5fd;
  font-size: 10px;
  font-family: inherit;
  padding: 1px 8px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.2px;
  flex-shrink: 0;
  margin-left: 4px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.battle-cell-retry:hover {
  background: rgba(99,179,237,0.22);
  border-color: rgba(99,179,237,0.55);
  color: #bfdbfe;
}
.battle-cell-retry:active { transform: translateY(1px); }

/* === Video lightbox (vid-modal-overlay) === */
/* .img-modal-overlay와 같은 backdrop을 쓰지만 video는 별도 룰 */
.vid-modal-overlay video {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  background: #000;
  cursor: default;
  outline: none;
}
.vid-modal-label {
  position: absolute;
  top: 18px; left: 22px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  pointer-events: auto;
  cursor: default;
}

/* 비디오 배틀 셀 — 클릭 시 줌인 가능함을 알리는 cursor */
.battle-cell-video-clickable {
  cursor: zoom-in;
}
.battle-cell-video-clickable:hover video {
  opacity: 0.92;
  transition: opacity 0.15s;
}

/* === ⭐ Save 버튼 — battle 셀 헤더 안 inline === */
.battle-cell-save {
  background: rgba(247,179,50,0.14);
  border: 1px solid rgba(247,179,50,0.40);
  color: #fcd34d;
  font-size: 11px;
  font-family: inherit;
  padding: 1px 7px;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.battle-cell-save:hover {
  background: rgba(247,179,50,0.24);
  border-color: rgba(247,179,50,0.65);
  color: #fde68a;
}
.battle-cell-save.is-saved {
  background: rgba(72,187,120,0.18);
  border-color: rgba(72,187,120,0.45);
  color: #6ee7b7;
  cursor: default;
}
.battle-cell-save:disabled { opacity: 0.6; cursor: default; }

/* Restored round 헤더 — 살짝 다른 톤 */
.battle-round.battle-round-restored {
  background: rgba(167,139,250,0.04);
  border-bottom-color: rgba(167,139,250,0.18);
}
.battle-cell.restored .battle-cell-status { color: #c4b5fd; }

/* 단일 모드 ⭐ Save 버튼 */
.result-save-btn {
  background: rgba(247,179,50,0.14);
  border: 1px solid rgba(247,179,50,0.40);
  color: #fcd34d;
  font-size: 11px;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.result-save-btn:hover {
  background: rgba(247,179,50,0.24);
  border-color: rgba(247,179,50,0.65);
  color: #fde68a;
}
.result-save-btn.is-saved {
  background: rgba(72,187,120,0.18);
  border-color: rgba(72,187,120,0.45);
  color: #6ee7b7;
  cursor: default;
}
.result-save-btn:disabled { opacity: 0.7; cursor: default; }

/* Restored 카드 좌측에 옅은 보라 표식 */
.result-card.restored {
  border-left: 3px solid rgba(167,139,250,0.45);
}
.result-card.restored.restored-forge {
  border-left-color: rgba(99,179,237,0.55);
}
.result-card.restored.restored-forge-final {
  border-left-color: rgba(72,187,120,0.55);
}

/* ===================================================================
   Header v2 — Terminal / pixel-art look (replaces monkey JPG)
   =================================================================== */

/* 픽셀 원숭이 마스코트 — inline SVG, 외부 의존 0 */
.header-pixel-mascot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: #14161a;
  border: 1px solid rgba(92, 242, 192, 0.35);
  border-radius: 4px;          /* 둥근 모서리 살짝만 — 터미널 윈도우 느낌 */
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 0 14px rgba(92,242,192,0.06);
  padding: 2px;
  position: relative;
}
.header-pixel-mascot::before {
  /* 터미널 컨테이너의 미세한 traffic-light dot 한 개 — 아주 작게 */
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #5cf2c0;
  box-shadow: 0 0 4px rgba(92,242,192,0.7);
  opacity: 0.55;
}
.header-pixel-mascot svg {
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* 기존 둥근 사진 로고는 제거(혹시 캐시된 마크업이 남아 있을 때 대비) */
.header .header-logo-img { display: none !important; }

/* 터미널 콘셉트 타이틀 — 굵은 monospace + 살짝 글로우 */
.header-title.header-title-terminal {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', 'Monaco',
               'Consolas', 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1;
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}
.header-title.header-title-terminal .term-prompt {
  color: #5cf2c0;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(92,242,192,0.35);
  margin-right: 2px;
}
.header-title.header-title-terminal .term-text {
  background: linear-gradient(90deg, #e2e8f0 0%, #c4f5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.header-title.header-title-terminal .term-caret {
  display: inline-block;
  margin-left: 3px;
  color: #5cf2c0;
  font-weight: 700;
  animation: term-blink 1.05s steps(1, end) infinite;
  text-shadow: 0 0 6px rgba(92,242,192,0.55);
}
@keyframes term-blink {
  0%, 50%   { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* === Header 배지 — 한 단계 더 은은하게 (사용자 요청) === */
.header-badge {
  font-size: 8px;
  background: transparent;
  color: #4a4f56;
  border: none;
  padding: 1px 4px;
  letter-spacing: 0.1px;
  font-weight: 400;
  opacity: 0.32;
  transition: opacity 0.2s, color 0.2s;
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  cursor: help;
  margin-left: auto;
}
.header-badge:hover {
  opacity: 0.75;
  color: #6a6f76;
}

/* ===================================================================
   Mode switcher v3 — group tones + spacing
   -------------------------------------------------------------------
   요구사항:
     A) Text Gen / Image Gen / Video Gen → 모음, 같은 톤
     B) Image Battle / Video Battle → 모음, 같은 톤 (배틀)
     C) Story Forge → B와 살짝만 다른 톤 (배틀 그룹 가까이 위치)
     D) API Guide → 살짝 거리 + 약간 다른 톤
   - 너무 튀던 보라/블루는 죽이고 슬레이트 톤으로 통일
   =================================================================== */

/* 두 mode-switcher 사이 거리 — 그룹간 간격 */
.mode-switcher + .mode-switcher {
  margin-left: 18px;     /* 그룹 사이 약간의 거리 */
}

/* 메인 그룹 — 슬레이트 배경 통일 */
.mode-switcher-main,
.mode-switcher-battle {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.05);
}

/* mode-tab 공통 — hover/active 톤 통일 */
.mode-tab {
  color: #94a3b8;
}
.mode-tab:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}

/* === Group A: Text Gen / Image Gen / Video Gen ===
   기본 슬레이트, active 시 옅은 텍스트 + 어두운 배경 (강조 너무 강하지 않게) */
.mode-switcher-main .mode-tab.active {
  background: rgba(255,255,255,0.10);
  color: #e2e8f0;
  box-shadow: none;
}

/* === Group B: Image Battle / Video Battle ===
   배틀 두 개를 옆에 모음. 톤은 메인과 같지만 active 시 옅은 청록(강조색)을
   띠 형태로만 살짝 — 너무 튀지 않게. */
.mode-tab-battle {
  background: transparent;
}
.mode-tab-battle:hover {
  background: rgba(92, 242, 192, 0.06);
  color: #cbd5e0;
}
.mode-tab-battle.active {
  background: rgba(92, 242, 192, 0.10);
  color: #5cf2c0;
  box-shadow: inset 0 -2px 0 rgba(92, 242, 192, 0.45);
  text-shadow: 0 0 6px rgba(92, 242, 192, 0.18);
}

/* === Group C: Story Forge ===
   배틀 그룹과 같은 박스 안이지만 active 시 옅은 보라 강조만 — 기본 hover는
   배틀과 동일 톤 (그룹 통일감 유지). */
.mode-tab-forge {
  background: transparent;
}
.mode-tab-forge:hover {
  background: rgba(167, 139, 250, 0.08);
  color: #cbd5e0;
}
.mode-tab-forge.active {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
  box-shadow: inset 0 -2px 0 rgba(167, 139, 250, 0.40);
  text-shadow: 0 0 6px rgba(167, 139, 250, 0.18);
}
/* Forge와 배틀 사이 약간의 공간 (같은 그룹 박스 안이지만 시각적 구분) */
.mode-tab-forge {
  margin-left: 8px;
}

/* === Group D: API Guide ===
   배틀 그룹에서 약간 떨어뜨려서 별도 그룹으로 인식되게. 톤은 살짝 다른
   미세한 회색 + 작게. 더 이상 amber/주황 톤은 쓰지 않음 (튀어서 제외). */
.mode-tab-api {
  margin-left: 20px;         /* 배틀 그룹과의 거리 */
  background: transparent;
  color: #6b7280;
  font-weight: 500;
  font-size: 12px;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.06);
  letter-spacing: 0;
}
.mode-tab-api:hover {
  color: #cbd5e0;
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.12);
}

/* ===================================================================
   Header v3 — 사이드바 폭에 맞춤 + 톤 통일
   사용자 요청:
     - 깜빡이 / $ / _ 제거 (HTML에서 삭제 완료)
     - 글씨 색 다른 UI랑 통일 (accent 톤)
     - 가로 길이를 왼쪽 sidebar(340px)에 맞춤
     - 글씨 너무 하얗고 굵게 → 옅게/얇게
     - 마스코트 외곽 박스 / 그린 dot 제거 (몸통만)
     - 폰트는 더 미래적인 monospace 사용
   =================================================================== */

/* === 마스코트 — 외곽 박스/그린 dot 제거, 픽셀 몸통만 === */
.header-pixel-mascot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  position: relative;
}
.header-pixel-mascot::before { content: none; display: none; }
.header-pixel-mascot svg {
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* 살짝의 그림자만 — 배경에 떠 있는 느낌 */
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.55));
}

/* === 타이틀 — 사이드바 폭에 맞춰 잘리도록 가로 제한 + 톤 통일 ===
   사이드바: 340px (main grid-template-columns: 340px 1fr).
   헤더 padding 14px 24px → 마스코트(28+12gap)와 타이틀이 그 안에 모두
   들어가도록 타이틀 max-width = 340 - 24(padding) - 28(mascot) - 12(gap) ≈ 276px.
   그래서 약 270~280px로 잡으면 사이드바 폭과 시각적으로 정확히 정렬됨. */
.header-title.header-title-terminal {
  /* Orbitron / Rajdhani / Audiowide 같은 sci-fi 폰트가 없는 환경을 고려해
     monospace로 fallback. 사이즈/굵기를 죽여서 차분한 미래 톤으로. */
  font-family: 'Orbitron', 'Rajdhani', 'Audiowide', 'JetBrains Mono',
               'Fira Code', 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1.6px;      /* 자간 넓혀 미래 톤 */
  line-height: 1.15;
  color: var(--accent-light); /* 다른 UI와 톤 통일 */
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  /* 사이드바 가로폭과 정렬: 마스코트 + gap 포함해 340px 안에 들어옴 */
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(74, 93, 126, 0.25);
}
.header-title.header-title-terminal .term-text {
  /* 그라데이션·-webkit-text-fill 모두 해제. 단색 accent 톤. */
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: currentColor !important;
  color: inherit !important;
  font-weight: 500;
  letter-spacing: 1.6px;
}
/* $, caret 룰은 HTML에서 요소 자체가 빠졌으니 안전망으로 숨김 */
.header-title.header-title-terminal .term-prompt,
.header-title.header-title-terminal .term-caret { display: none !important; }

/* ===================================================================
   Header v4 — brand 타이틀 (Pretendard, 안전 fallback)
   -------------------------------------------------------------------
   - Pretendard 웹폰트가 로드되면 그것을 쓰고, 실패/미로딩 환경에서는
     system-ui → -apple-system → "Apple SD Gothic Neo" → "Malgun Gothic"
     → Helvetica → sans-serif 로 fallback. 어느 OS에서든 깨지지 않음.
   - 이전 .header-title-terminal에 있던 monospace 강제·텍스트 그라데이션
     등은 .header-title-brand에는 적용되지 않으므로 클래스 명만 바꿔도
     자연스럽게 새 톤으로 전환된다.
   =================================================================== */

/* 안전한 변수 — 다른 곳에서도 일관 사용 가능 */
:root {
  --font-brand: 'Pretendard Variable', 'Pretendard',
                -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
                'Noto Sans KR', 'Malgun Gothic', 'Segoe UI', Roboto,
                'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.header-title.header-title-brand {
  font-family: var(--font-brand);
  font-size: 15px;
  font-weight: 600;            /* Pretendard semi-bold — 또렷하되 부담 적게 */
  letter-spacing: -0.01em;     /* 한글에 자연스러운 자간 */
  line-height: 1.15;
  /* 흰색-그레이 사이 톤 — 어두운 헤더 배경에서 또렷이 읽힘 */
  color: #d8dde6;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  /* 텍스트 풀로 보이도록 폭 제한 해제. 한 줄로만. */
  max-width: none;
  overflow: visible;
  white-space: nowrap;
  text-transform: none;        /* uppercase 해제, 자연스러운 brand 톤 */
  text-shadow: none;
  flex-shrink: 0;              /* 다른 요소가 밀어도 잘리지 않게 */
}
.header-title.header-title-brand .term-text {
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: currentColor !important;
  color: inherit !important;
  font-weight: 600;
  font-family: var(--font-brand);
  letter-spacing: -0.01em;
}

/* 마스코트는 영구 제거 — 혹시 캐시된 마크업이 남아 있을 때 대비해 숨김 */
.header .header-pixel-mascot { display: none !important; }

/* ===================================================================
   Advanced Options 접이 — 사이드바의 Resolution 아래 부가 옵션을
   드롭다운(접이) 형태로 묶어 시각적 노이즈를 줄임.
   - 닫혔을 때: 한 줄짜리 토글만 보임
   - 열렸을 때: 안에 있는 field-group 들이 그대로 펼쳐짐
   - 디자인은 기존 톤 유지(테두리/색감/letter-spacing)만 살짝 정돈
   =================================================================== */
.advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #cbd5e0;
  user-select: none;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.advanced-toggle:hover {
  background: rgba(255,255,255,0.03);
  color: #e2e8f0;
}
.advanced-toggle .adv-label { letter-spacing: 0.06em; }
.advanced-toggle .adv-arrow {
  font-size: 9px;
  color: var(--text-dim, #888);
  transition: transform 0.2s ease;
}
.advanced-toggle.open .adv-arrow { transform: rotate(90deg); }

.advanced-body {
  /* 닫혔을 때 완전히 숨김. 열림 시 자연 높이로 확장 */
  display: none;
  margin-top: 4px;
  padding-top: 2px;
  border-top: 1px dashed rgba(255,255,255,0.05);
}
.advanced-body.open { display: block; }

/* ===================================================================
   Header v5 — PNG 로고 이미지로 텍스트 교체
   - 빨간 박스(사용자 요청) 까지 로고를 키운다.
   - 사이드바 340px 폭에서 헤더 padding(좌 32px) 을 빼면 약 308px 가 로고가
     쓸 수 있는 가로 공간. max-width 296px / height 42px 로 잡고, 모드
     스위처는 사이드바 우측 경계 직후부터 시작.
   - 1080×157 비율(약 6.88:1) 그대로 유지 → height 42px 일 때 자연 폭
     약 289px. max-width 296 안에 안전 수용.
   =================================================================== */
.header-title.header-title-brand {
  display: inline-flex;
  align-items: center;
  padding: 0;
  margin: 0;
  line-height: 1;
  flex-shrink: 0;
  /* 사이드바 폭(340) − 헤더 좌 padding(32) − 약간의 여유(12) ≈ 296px */
  max-width: 296px;
  width: auto;
}
.header-logo-png {
  display: block;
  height: 42px;        /* 38 → 42 (살짝 더 크게) */
  width: auto;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0.96;
}

/* 헤더: 로고를 살짝 오른쪽으로 밀고(좌 padding 24 → 32) 총 높이는
   65px 부근으로 유지(42(logo) + 22(padding) ≈ 64). main grid 의
   calc(100vh - 65px) 와 정렬. */
.header { padding: 11px 24px 11px 32px; gap: 14px; }

/* 첫 번째 모드 스위처는 사이드바(340px) 우측 경계에서 시작.
   계산: 사이드바 우측 경계 = 340. 첫 모드 스위처가 그 위치에서 시작하도록,
   로고 컨테이너 우측 끝점부터 사이드바 경계까지의 공백을 명시.
   (로고 컨테이너는 좌 padding 32 + max-width 296 = 끝점 328 → 사이드바
   경계 340 까지 12px 더 가야 함. flex gap 14 가 자동 적용되므로 mode
   switcher 시작점 ≈ 342 — 사이드바 경계 바로 옆.) */
.header .mode-switcher { margin-left: 14px; }
/* 단, 메인 모드 스위처가 정확히 사이드바 경계와 시각 정렬되도록 약간의
   추가 push — 사용자 캡처 기준 빨간 라인 우측에서 "Text Gen" 시작. */
.header .mode-switcher-main { margin-left: 18px; }

/* 시각적으로는 안 보이지만 스크린리더/SEO 에는 잡히는 텍스트 */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =================================================================
 *  Battle Engine Picker — 헤더 바 밑에 가로로 늘어선 칩 리스트
 *  (이미지/비디오 배틀 시작 전 호출할 엔진 선택)
 * ================================================================= */
.battle-engine-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.battle-engine-picker-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim, #888);
  font-weight: 500;
}
.battle-engine-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}
.battle-engine-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.battle-engine-chip input[type="checkbox"] {
  width: 12px;
  height: 12px;
  accent-color: #5cf2c0;
  cursor: pointer;
}
.battle-engine-chip:hover { background: rgba(255,255,255,0.06); color: #ddd; }
.battle-engine-chip.is-on {
  background: rgba(92,242,192,0.10);
  border-color: rgba(92,242,192,0.45);
  color: #d6fff0;
}
.battle-engine-chip.is-on .battle-engine-chip-label { font-weight: 500; }
.battle-engine-picker-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.battle-engine-picker-btn {
  background: none;
  border: none;
  color: var(--text-dim, #888);
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 2px 4px;
  text-transform: lowercase;
}
.battle-engine-picker-btn:hover { color: #5cf2c0; }

/* =================================================================
 *  Battle Results — masonry-like 자유 배치
 *  이전: 9-col 또는 4-col fixed grid + 모든 셀 aspect-ratio 강제 + object-fit:cover
 *  지금: 12-col CSS grid + 셀당 col-span(data-size 1/2/3) + 셀 안 미디어는 자연 비율 유지
 *  → 셀 크기가 들쭉날쭉, 미디어가 원본 비율로 보이고, 평행 끊김 없는 느낌.
 * ================================================================= */
.battle-grid-image .battle-round-grid,
.battle-grid-video .battle-round-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: auto;
  grid-auto-flow: dense;   /* 빈 칸 채우기 — 자유로운 패치워크 느낌 */
  gap: 8px;
  overflow: visible;
}
/* 이미지 배틀의 옛 가로 스크롤 한 줄 강제 해제 */
.battle-grid-image .battle-round-grid {
  overflow-x: visible;
  overflow-y: visible;
}

/* 셀 — col-span 은 data-size 로 결정. 기본 3칸(= 4셀/행), L=4칸, XL=6칸. */
.battle-grid-image .battle-cell,
.battle-grid-video .battle-cell {
  grid-column: span 3;
  aspect-ratio: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  min-width: 0 !important;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #0e1014;
  border: 1px solid rgba(255,255,255,0.06);
}
.battle-grid-image .battle-cell[data-size="2"],
.battle-grid-video .battle-cell[data-size="2"] { grid-column: span 4; }
.battle-grid-image .battle-cell[data-size="3"],
.battle-grid-video .battle-cell[data-size="3"] { grid-column: span 6; }

/* 셀 안 미디어 — 원본 비율 유지(contain 아님). width=100%, height=auto. */
.battle-grid-image .battle-cell-body,
.battle-grid-video .battle-cell-body {
  position: relative !important;
  flex: 0 0 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 0 !important;
  display: block !important;
  overflow: hidden;
}
.battle-grid-image .battle-cell-body img,
.battle-grid-video .battle-cell-body video,
.battle-grid-video .battle-cell-body img {
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  object-fit: cover !important;   /* 미디어 자체는 셀에 꽉, 자연 비율은 셀이 결정 */
  display: block !important;
  border-radius: 0;
  background: #0e1014;
}

/* placeholder/spinner — 다시 절대값 inset 해제 */
.battle-grid-image .battle-cell-body > .battle-spinner,
.battle-grid-image .battle-cell-body > .battle-cell-placeholder,
.battle-grid-video .battle-cell-body > .battle-spinner,
.battle-grid-video .battle-cell-body > .battle-cell-placeholder {
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  height: 180px !important;
  margin: 0 !important;
}

/* 비디오 라운드도 한 화면 fit 강제 해제 — 자유롭게 흘러내림 */
.battle-grid-video .battle-round {
  display: block !important;
  height: auto !important;
}
.battle-grid-video .battle-round-grid {
  grid-template-rows: none !important;
  flex: none !important;
  max-height: none !important;
  overflow: visible !important;
}

/* 결과 영역 — 세로 스크롤. 부모(.gen-area)가 flex column 이고
   prompt-bar 가 그 아래 형제로 있으므로, .battle-grid 가 flex 안에서
   남은 공간을 차지하고 그 안에서 자유 스크롤되어야 한다.
   - flex:1 + min-height:0  → flex item 의 자연 높이가 콘텐츠 크기로
     부풀어오르는 것을 막아 부모가 부여한 컴퓨티드 높이로 고정
   - padding-bottom 충분히 → 마지막 셀이 prompt-bar 와 안 겹치게 여유
   (사용자 보고: 마지막 영상이 짤려서 스크롤로 끝까지 못 봄) */
.battle-grid {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px 28px;
}

/* 미디어 쿼리 재정의 — 좁아질수록 col 수 감소 (12 → 8 → 6 → 4) */
@media (max-width: 1400px) {
  .battle-grid-image .battle-round-grid,
  .battle-grid-video .battle-round-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
  .battle-grid-image .battle-cell,
  .battle-grid-video .battle-cell { grid-column: span 2; }
  .battle-grid-image .battle-cell[data-size="2"],
  .battle-grid-video .battle-cell[data-size="2"] { grid-column: span 3; }
  .battle-grid-image .battle-cell[data-size="3"],
  .battle-grid-video .battle-cell[data-size="3"] { grid-column: span 4; }
}
@media (max-width: 900px) {
  .battle-grid-image .battle-round-grid,
  .battle-grid-video .battle-round-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .battle-grid-image .battle-cell,
  .battle-grid-video .battle-cell { grid-column: span 3; }
  .battle-grid-image .battle-cell[data-size="2"],
  .battle-grid-video .battle-cell[data-size="2"] { grid-column: span 4; }
  .battle-grid-image .battle-cell[data-size="3"],
  .battle-grid-video .battle-cell[data-size="3"] { grid-column: span 6; }
}
@media (max-width: 540px) {
  .battle-grid-image .battle-round-grid,
  .battle-grid-video .battle-round-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .battle-grid-image .battle-cell,
  .battle-grid-video .battle-cell { grid-column: span 4; }
  .battle-grid-image .battle-cell[data-size="2"],
  .battle-grid-video .battle-cell[data-size="2"] { grid-column: span 4; }
  .battle-grid-image .battle-cell[data-size="3"],
  .battle-grid-video .battle-cell[data-size="3"] { grid-column: span 4; }
}

/* 셀 헤더 — 미디어 위에 항상 떠 있는 오버레이 (호버 무관, 항상 표시) */
.battle-grid-image .battle-cell-header,
.battle-grid-video .battle-cell-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);
  font-size: 11px;
  color: #ddd;
  opacity: 1;                 /* 호버 여부와 무관하게 항상 표시 */
  pointer-events: none;       /* 헤더 영역 자체는 클릭 통과 — 버튼만 받음 */
}
.battle-grid-image .battle-cell-header > *,
.battle-grid-video .battle-cell-header > * { pointer-events: auto; }
.battle-grid-image .battle-cell-engine,
.battle-grid-video .battle-cell-engine {
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* 영상 셀의 우측 ⭐ 와 ⤢ 가능 — header position:absolute 안에서 정렬 유지 */
.battle-grid-image .battle-cell-save,
.battle-grid-video .battle-cell-save {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  color: #f0c574;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}

/* === Battle 셀 Prompt 버튼 — 호버 무관 항상 표시하되 흐릿하게 === */
.battle-cell-prompt {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(203,213,224,0.45);
  border-radius: 4px;
  height: 22px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  cursor: pointer;
  opacity: 0.42;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
  pointer-events: auto;
}
.battle-cell-prompt:hover {
  background: rgba(0,0,0,0.45);
  border-color: rgba(92,242,192,0.45);
  color: #5cf2c0;
  opacity: 1;
}

/* === Prompt 모달 (셀 Prompt 버튼 클릭) === */
.prompt-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: imgmodal-fade 0.15s ease-out;
}
.prompt-modal-card {
  background: #14171c;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  width: min(720px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}
.prompt-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.prompt-modal-title {
  font-size: 11px;
  font-weight: 700;
  color: #5cf2c0;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.prompt-modal-actions { display: flex; gap: 6px; }
.prompt-modal-copy,
.prompt-modal-close {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  color: #cbd5e0;
  border-radius: 4px;
  height: 26px;
  padding: 0 10px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.prompt-modal-close { width: 28px; padding: 0; font-size: 16px; line-height: 1; }
.prompt-modal-copy:hover,
.prompt-modal-close:hover {
  background: rgba(92,242,192,0.15);
  border-color: rgba(92,242,192,0.45);
  color: #5cf2c0;
}
.prompt-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.prompt-modal-text {
  margin: 0;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.55;
  color: #d4dae1;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   GALLERY — 메인화면 쇼케이스 (masonry, CDN-backed)
   ============================================================ */
.gallery-area {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  box-sizing: border-box;
  background: #0a0c10;
}
.gallery-area.active { display: block; }

/* CSS columns 기반 masonry — 빈틈 없는 타일 */
.gallery-grid {
  column-count: 5;
  column-gap: 4px;
  padding: 0;
}
@media (max-width: 1600px) { .gallery-grid { column-count: 4; } }
@media (max-width: 1200px) { .gallery-grid { column-count: 3; } }
@media (max-width:  800px) { .gallery-grid { column-count: 2; } }
@media (max-width:  500px) { .gallery-grid { column-count: 1; } }

.gallery-item {
  break-inside: avoid;
  margin-bottom: 4px;
  position: relative;
  display: block;
  width: 100%;
  background: #14171c;
  cursor: pointer;
  overflow: hidden;
  border-radius: 2px;
}
.gallery-item img,
.gallery-item video {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}
.gallery-item:hover img,
.gallery-item:hover video { opacity: 0.92; }

/* 우상단 종류 라벨 (Image / Video, 다크톤, 투명도) */
.gallery-kind-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.55);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 3px;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* 호버 시 좌하단 엔진 라벨 (살짝) */
.gallery-item-meta {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0,0,0,0.55);
  color: rgba(226,232,240,0.85);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.gallery-item:hover .gallery-item-meta { opacity: 1; }
.gallery-item-engine {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  letter-spacing: 0.3px;
}

/* Empty state */
.gallery-empty {
  column-span: all;
  text-align: center;
  padding: 80px 20px;
  color: rgba(226,232,240,0.4);
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}
.gallery-empty-icon {
  font-size: 28px;
  letter-spacing: 4px;
  opacity: 0.3;
  margin-bottom: 14px;
}
.gallery-empty-text {
  font-size: 14px;
  margin-bottom: 6px;
  color: rgba(226,232,240,0.6);
}
.gallery-empty-sub {
  font-size: 11px;
  opacity: 0.7;
}

/* Gallery mode body — 사이드바 숨기는 건 기존 battle-mode 클래스가 처리 */
body.gallery-mode .sidebar { display: none; }
body.gallery-mode .main { padding: 0; }

/* ============================================================
   ◇ Gallery Save 버튼 — 결과물 카드 안의 흐릿한 저장 버튼
   ============================================================ */
.gallery-save-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(203,213,224,0.45);
  border-radius: 4px;
  height: 22px;
  width: 26px;
  padding: 0;
  font-size: 13px;
  line-height: 20px;
  font-family: inherit;
  cursor: pointer;
  opacity: 0.42;
  margin-left: 4px;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
  pointer-events: auto;
}
.gallery-save-btn:hover {
  background: rgba(0,0,0,0.45);
  border-color: rgba(92,242,192,0.55);
  color: #5cf2c0;
  opacity: 1;
}
.gallery-save-btn.is-saving {
  opacity: 0.7;
  cursor: wait;
}
.gallery-save-btn.is-saved {
  opacity: 0.85;
  color: #6ee7b7;
  border-color: rgba(72,187,120,0.45);
  cursor: default;
}

/* ============================================================
   GALLERY MODAL — 아이템 클릭 시 상세 (원본+엔진+prompt+ref+삭제)
   ============================================================ */
.gallery-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: imgmodal-fade 0.15s ease-out;
}
.gallery-modal-card {
  background: #14171c;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  width: min(1400px, 96vw);
  height: min(880px, 92vh);
  display: flex;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(0,0,0,0.7);
  /* sans-serif 로 통일 — 모노스페이스 톤 제거 */
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display',
               'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: #f1f5f9;
}
.gallery-modal-media {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}
.gallery-modal-media img,
.gallery-modal-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ──────────────── Side panel ──────────────── */
.gallery-modal-side {
  /* 1600px 이상 화면에서는 440px, 그 이하는 360px 으로 좁혀서 미디어 표시 영역 확보. */
  width: 360px;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  background: #0f1217;
}
@media (min-width: 1600px) {
  .gallery-modal-side { width: 440px; }
}
.gmodal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.gmodal-tag {
  font-size: 11px;
  font-weight: 700;
  color: #5cf2c0;
  letter-spacing: 1.2px;
}
.gmodal-close {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: #cbd5e0;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.gmodal-close:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

.gmodal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* 섹션 헤딩 ── Prompt / Settings */
.gmodal-section { display: flex; flex-direction: column; gap: 12px; }
.gmodal-h {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #ffffff;
}

/* Prompt 본문 — 큼지막한 sans-serif, 답답함 X */
.gmodal-prompt-text {
  margin: 0;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Prompt 섹션 안의 ref 썸네일 — 작게 좌측 정렬 */
.gmodal-ref-thumb {
  display: inline-block;
  margin: 0 0 4px;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255,255,255,0.10);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.gmodal-ref-thumb img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
}
.gmodal-ref-thumb:hover {
  border-color: rgba(92,242,192,0.55);
  transform: translateY(-1px);
}

/* Settings ── 3 컬럼 grid */
.gmodal-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 18px;
}
.gmodal-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.gmodal-stat-label {
  font-size: 13px;
  color: rgba(203,213,224,0.55);
  font-weight: 500;
}
.gmodal-stat-value {
  font-size: 16px;
  font-weight: 600;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  word-break: break-word;
}
.gmodal-stat-value.gmodal-stat-strong { font-weight: 700; }
.gmodal-stat-icon {
  font-size: 16px;
  color: rgba(203,213,224,0.65);
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  flex-shrink: 0;
}

/* Settings 안의 한 줄 (label 위 / value 아래) — File type, Saved */
.gmodal-stat.gmodal-stat-row {
  flex-direction: column;
  gap: 4px;
}
.gmodal-stat-muted {
  font-size: 13px;
  font-weight: 400;
  color: rgba(203,213,224,0.55);
}

/* Actions bar — 하단 고정 */
.gmodal-actions {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  background: #0f1217;
}
.gmodal-action {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e2e8f0;
  border-radius: 6px;
  height: 38px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.gmodal-action:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.28);
  color: #ffffff;
}
.gmodal-action-delete {
  background: rgba(229,62,62,0.06);
  border-color: rgba(229,62,62,0.25);
  color: #fc8181;
}
.gmodal-action-delete:hover {
  background: rgba(229,62,62,0.14);
  border-color: rgba(229,62,62,0.5);
  color: #fca5a5;
}

/* Side panel 폭이 좁을 때 (모바일/태블릿) */
@media (max-width: 1100px) {
  .gallery-modal-card {
    flex-direction: column;
    height: min(94vh, 880px);
  }
  .gallery-modal-side {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    max-height: 50%;
  }
  .gallery-modal-media { min-height: 45%; }
}

/* Gallery 탭 — 다른 탭과 톤은 같지만 살짝 그린 액센트 */
.mode-tab.mode-tab-gallery.active {
  color: #5cf2c0;
  border-bottom-color: #5cf2c0;
}

/* ============================================================
   RAW (compliance-check OFF) — 내부 테스트용 변종 표시
   ============================================================ */
/* select 가 _raw 옵션을 선택했을 때 빨간 글로우 + 좌측 점 */
.field-select.is-raw {
  border-color: rgba(229, 62, 62, 0.7);
  box-shadow: 0 0 0 1px rgba(229,62,62,0.45),
              0 0 12px rgba(229,62,62,0.35);
  color: #fc8181;
}
.field-select.is-raw:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(229,62,62,0.55),
              0 0 14px rgba(229,62,62,0.45);
}

/* select 옆에 RAW 표시 라벨 — JS 에서 동적 추가 가능, 일단 기본 스타일 */
.raw-badge {
  display: inline-block;
  background: rgba(229,62,62,0.12);
  border: 1px solid rgba(229,62,62,0.55);
  color: #fc8181;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Gallery 모달 사이드바 안의 RAW 배지 (compliance_off 마킹된 항목) */
.gmodal-raw-badge {
  display: inline-block;
  background: rgba(229,62,62,0.12);
  border: 1px solid rgba(229,62,62,0.55);
  color: #fc8181;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ============================================================
   Header ✕ Clear All Sessions — 전체 세션 한 번에 비우기
   ============================================================ */
.header-wipe-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(203,213,224,0.55);
  border-radius: 5px;
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  font-family: inherit;
  cursor: pointer;
  margin-left: 8px;
  opacity: 0.55;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.header-wipe-btn:hover {
  background: rgba(229,62,62,0.12);
  border-color: rgba(229,62,62,0.5);
  color: #fc8181;
  opacity: 1;
}
.header-wipe-btn.is-done {
  background: rgba(72,187,120,0.15);
  border-color: rgba(72,187,120,0.5);
  color: #6ee7b7;
  opacity: 1;
}

/* 헤더의 ✕ Clear Expired — Clear All Sessions 보다 한 톤 차분히 (회색→호박빛) */
.header-clear-expired-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(203,213,224,0.45);
  border-radius: 5px;
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  font-family: inherit;
  cursor: pointer;
  margin-left: 8px;
  opacity: 0.5;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.header-clear-expired-btn:hover {
  background: rgba(240,165,0,0.10);
  border-color: rgba(240,165,0,0.5);
  color: #f0c574;
  opacity: 1;
}
.header-clear-expired-btn.is-done {
  background: rgba(72,187,120,0.15);
  border-color: rgba(72,187,120,0.5);
  color: #6ee7b7;
  opacity: 1;
}
