/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --bg-main: #212121;
  --bg-sidebar: #171717;
  --bg-input: #2f2f2f;
  --bg-user-bubble: #2f2f2f;
  --bg-ai-bubble: #1e1e1e;
  --bg-card: #2a2a2a;
  --bg-card-hover: #333;
  --border: #3a3a3a;
  --text-primary: #ececec;
  --text-secondary: #9b9b9b;
  --text-muted: #666;
  --accent: #10a37f;
  --accent-hover: #0e9470;
  --gold: #f5c518;
  --gold-dark: #d4a400;
  --danger: #e53e3e;
  --radius: 12px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow: hidden;
}

/* ===== Layout ===== */
body { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: transform var(--transition), width var(--transition), min-width var(--transition);
  overflow: hidden;
  z-index: 10;
}
.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.sidebar-user-id {
  font-size: 11px;
  color: #888;
  text-align: center;
  margin-bottom: 12px;
}

.btn-new-chat {
  width: 100%;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition);
  text-align: center;
}
.btn-new-chat:hover { background: var(--accent-hover); }

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.sidebar-history::-webkit-scrollbar { width: 4px; }
.sidebar-history::-webkit-scrollbar-track { background: transparent; }
.sidebar-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.history-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 20px 8px;
}

.history-week-btn {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.history-week-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.history-week-btn.active { background: var(--bg-card); color: var(--text-primary); }

.history-week-btn .week-label {
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.history-week-btn .week-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Session sidebar items ===== */
.history-group-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 10px 4px;
}
.history-group-header.legacy-label {
  padding-top: 16px;
  opacity: 0.6;
}

.session-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--transition), color var(--transition);
  display: block;
  overflow: hidden;
}
.session-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.session-btn.active { background: var(--bg-card); color: var(--text-primary); }

.session-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  margin-bottom: 2px;
}
.session-meta {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 8px; }

.btn-sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.btn-sidebar-toggle:hover { color: var(--text-primary); }

.model-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 28px 7px 12px;
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%239b9b9b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition);
}
.model-select:focus { outline: none; border-color: var(--accent); }
.model-select.council-mode {
  border-color: var(--gold);
  color: var(--gold);
  background-color: rgba(245, 197, 24, 0.08);
}

/* ===== Chat Area ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.welcome-icon { margin-bottom: 16px; }
.welcome-logo { width: 80px; height: 80px; object-fit: cover; border-radius: 50%; }
.chat-welcome h2 { font-size: 22px; color: var(--text-primary); margin-bottom: 8px; font-weight: 600; }
.chat-welcome p { font-size: 14px; }

.messages { display: flex; flex-direction: column; gap: 20px; width: 100%; }

/* ===== Message Bubbles ===== */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.msg-row.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.msg-avatar.ai-avatar { background: var(--accent); color: #fff; }
.msg-avatar.user-avatar { background: #4a4a4a; color: #fff; }

.msg-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.msg-row.user .msg-bubble {
  background: var(--bg-user-bubble);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}
.msg-row.ai .msg-bubble {
  background: transparent;
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
  padding: 4px 0;
}

/* Markdown inside bubbles */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin-top: 16px; margin-bottom: 8px; font-weight: 600;
}
.msg-bubble h1 { font-size: 1.4em; }
.msg-bubble h2 { font-size: 1.2em; }
.msg-bubble h3 { font-size: 1.05em; }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin-bottom: 8px; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble code {
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #e06c75;
}
.msg-bubble pre {
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  margin: 10px 0;
  position: relative;
}
.msg-bubble pre code {
  background: transparent;
  padding: 14px 16px;
  display: block;
  overflow-x: auto;
  color: #abb2bf;
  font-size: 0.85em;
  line-height: 1.6;
}
.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.msg-bubble th { background: var(--bg-card); font-weight: 600; }
.msg-bubble tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.msg-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
}
.msg-bubble a { color: var(--accent); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }

/* Inline image in chat */
.chat-image {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  display: block;
  object-fit: cover;
  border: 1px solid var(--border);
  transition: opacity var(--transition);
}
.chat-image:hover { opacity: 0.85; }

/* ===== Council Card ===== */
.council-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  margin-bottom: 4px;
}
.council-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  gap: 10px;
}
.council-card-header:hover { background: var(--bg-card-hover); }
.council-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
.council-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-gpt { background: rgba(16, 163, 127, 0.2); color: #10a37f; }
.badge-claude { background: rgba(245, 197, 24, 0.15); color: var(--gold); }
.badge-gemini { background: rgba(66, 133, 244, 0.2); color: #4285f4; }
.badge-table { background: rgba(168, 85, 247, 0.2); color: #a855f7; }

.council-chevron {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform var(--transition);
}
.council-card.expanded .council-chevron { transform: rotate(180deg); }

.council-card-body {
  display: none;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-primary);
  overflow-x: auto;
}
.council-card.expanded .council-card-body { display: block; }
.council-card-body.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

/* Council card 비교표 테이블 */
.council-card-body .table-wrapper {
  overflow-x: auto;
  margin: 16px 0;
}
.council-card-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
  min-width: 600px;
}
.council-card-body th,
.council-card-body td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
}
.council-card-body th { background: var(--bg-card); font-weight: 600; }
.council-card-body tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
/* 컬럼 너비: 카테고리 15% | GPT 25% | Claude 25% | Gemini 25% | 요약 10% */
.council-card-body th:nth-child(1),
.council-card-body td:nth-child(1) { width: 15%; font-weight: bold; }
.council-card-body th:nth-child(2),
.council-card-body td:nth-child(2) { width: 25%; }
.council-card-body th:nth-child(3),
.council-card-body td:nth-child(3) { width: 25%; }
.council-card-body th:nth-child(4),
.council-card-body td:nth-child(4) { width: 25%; }
.council-card-body th:nth-child(5),
.council-card-body td:nth-child(5) { width: 10%; }

/* ===== Council Progress ===== */
.council-progress {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}
.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 360px;
  margin: 0 auto;
}
.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.progress-step span {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.progress-step.active span { color: var(--gold); }
.progress-step.done span { color: var(--accent); }
.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border);
  transition: all var(--transition);
}
.progress-step.active .step-dot {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(245, 197, 24, 0.5);
  animation: pulse 1s infinite;
}
.progress-step.done .step-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 60px;
  margin-bottom: 14px;
  transition: background var(--transition);
}
.progress-line.done { background: var(--accent); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(245,197,24,0.4); }
  50% { box-shadow: 0 0 14px rgba(245,197,24,0.8); }
}

/* ===== Input Area ===== */
.input-area {
  padding: 12px 16px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-main);
  position: relative;
  flex-shrink: 0;
}
.input-area.drag-over { background: rgba(16, 163, 127, 0.05); }

.dropzone-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(16, 163, 127, 0.12);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  z-index: 20;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}
.input-area.drag-over .dropzone-overlay { display: flex; }

.file-preview-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.file-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.file-preview-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  display: block;
}
.file-preview-item .doc-thumb {
  width: 64px;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  padding: 4px;
  text-align: center;
  word-break: break-all;
  line-height: 1.2;
}
.file-preview-item .doc-thumb .doc-icon { font-size: 22px; }
.file-preview-item .btn-remove-file {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition);
}
.file-preview-item .btn-remove-file:hover { background: var(--danger); }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color var(--transition);
}
.input-row:focus-within { border-color: var(--accent); }

.btn-attach {
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 4px;
  flex-shrink: 0;
  transition: color var(--transition);
  line-height: 1;
  user-select: none;
}
.btn-attach:hover { color: var(--text-primary); }

.message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  outline: none;
  font-family: inherit;
}
.message-input::placeholder { color: var(--text-muted); }
.message-input::-webkit-scrollbar { width: 4px; }
.message-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.btn-send {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  padding: 7px 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), opacity var(--transition);
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-send.stop-button {
  background: #ff4444;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-send.stop-button:hover { background: #ff6666; }
.cancelled-notice { color: #888; font-size: 12px; font-style: italic; }

/* ===== Loading dots ===== */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ===== Image Modal ===== */
.img-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.img-modal.open { display: flex; }
.img-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  cursor: pointer;
}
.img-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  object-fit: contain;
  z-index: 1;
}

/* ===== Security ===== */
.sidebar-security {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

.message-blocked {
  border: 2px solid #ff4444;
  background: #2d1111;
  border-radius: 12px;
  padding: 20px;
  margin: 10px 0;
  width: 100%;
}
.blocked-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.warning-icon { font-size: 28px; }
.warning-title { color: #ff6b6b; font-size: 18px; font-weight: 700; }
.warning-text { color: #ffaaaa; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.blocked-keyword { color: #ff8888; font-size: 13px; margin-bottom: 8px; }
.blocked-keyword strong {
  color: #ff4444;
  background: #3d1111;
  padding: 2px 6px;
  border-radius: 4px;
}
.report-notice {
  color: #888;
  font-size: 12px;
  border-top: 1px solid #3a1111;
  padding-top: 8px;
}

.input-row.security-warning {
  border-color: #f0a500;
  background: rgba(240, 165, 0, 0.04);
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px;
  flex-shrink: 0;
}

/* ===== Council Confirm Modal ===== */
.council-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.council-confirm-overlay.visible { opacity: 1; }

.council-confirm-box {
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 36px;
  max-width: 440px;
  width: calc(100% - 40px);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(10px);
  transition: transform 0.2s ease;
}
.council-confirm-overlay.visible .council-confirm-box { transform: translateY(0); }

.council-confirm-icon { font-size: 40px; margin-bottom: 12px; }

.council-confirm-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.council-confirm-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 12px;
}
.council-confirm-body strong { color: var(--gold); }

.council-confirm-question {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.council-confirm-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.council-confirm-btn {
  padding: 10px 28px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
}
.council-confirm-btn:hover { opacity: 0.85; }

.council-confirm-btn.cancel {
  background: #3a3a3a;
  color: var(--text-secondary);
}
.council-confirm-btn.cancel:hover { background: #444; opacity: 1; }

.council-confirm-btn.proceed {
  background: var(--gold);
  color: #1a1200;
}
.council-confirm-btn.proceed:hover { background: var(--gold-dark); opacity: 1; }

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
.sidebar-overlay.visible { display: block; }

/* ===== Scrollbar global ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

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

/* 1920px 이상: 본문 최대 폭 제한, 가운데 정렬 */
@media (min-width: 1920px) {
  .chat-area { padding: 24px calc((100% - 1200px) / 2 + 32px); }
  .input-area { padding-left: calc((100% - 1200px) / 2 + 16px); padding-right: calc((100% - 1200px) / 2 + 16px); }
}

/* 1024~1919px: 본문 width 100%, 여유있는 패딩 */
@media (min-width: 1024px) and (max-width: 1919px) {
  .chat-area { padding: 24px 40px; }
}

/* 768px 이하: 사이드바 오버레이, 본문 풀스크린 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
  }
  .main-content {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* 모바일 브라우저 주소창 변화 대응 */
  }
  .chat-area {
    flex: 1;
    min-height: 0; /* flex 스크롤 핵심: min-height 기본값 auto를 0으로 재정의 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS 모멘텀 스크롤 */
    padding: 16px 16px;
    padding-bottom: 100px; /* 하단 고정 입력창 공간 확보 */
  }
  .msg-bubble { max-width: 92%; }
  .council-card-body { padding: 10px 12px; }

  /* 입력창 하단 고정 */
  .input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-top: 1px solid var(--border);
    padding-bottom: max(8px, env(safe-area-inset-bottom)); /* iOS 홈바 대응 */
  }

  /* 푸터 숨김 (입력창 고정으로 가려지므로) */
  .app-footer { display: none; }

  /* 햄버거 버튼 터치 영역 확대 */
  .btn-sidebar-toggle {
    font-size: 22px;
    padding: 6px 10px;
  }
}
