@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;600;700&family=Noto+Sans+KR:wght@400;500;700&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
  --bg:         #f7f6f2;
  --surface:    #ffffff;
  --surface2:   #f0efe9;
  --border:     #dddad2;
  --border2:    #c8c4b8;
  --accent:     #c0392b;
  --accent-lt:  #fde8e6;
  --accent-dk:  #96291e;
  --green:      #3a6b30;
  --green-lt:   #e6f0e4;
  --text:       #0d0d0b;
  --text-md:    #1e1e1a;
  --text-dim:   #555550;
  --sidebar-w:  250px;
  --shadow:     0 2px 16px rgba(0,0,0,0.09);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.13);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 400;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 26px 22px 18px;
  border-bottom: 1px solid var(--border);
}
.logo-svg-wrap {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text .ko {
  font-family: 'Noto Serif KR', serif;
  font-size: 18px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
}
.logo-text .en {
  font-size: 11px; font-weight: 500;
  color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-section { padding: 18px 14px 6px; }
.sidebar-section-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0 8px; margin-bottom: 6px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  text-decoration: none;
  color: var(--text-md);
  font-size: 15px; font-weight: 500;
  transition: all 0.15s; cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-lt); color: var(--accent); font-weight: 700; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
  margin-top: auto; padding: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-footer-info { font-size: 12px; font-weight: 500; color: var(--text-dim); line-height: 1.6; }
.status-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 2px var(--green-lt);
}

/* ── MAIN ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── TOPBAR ── */
.topbar {
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  padding: 15px 32px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 18px; font-weight: 700; color: var(--text);
}
.topbar-sub { font-size: 13px; font-weight: 500; color: var(--text-dim); margin-left: 4px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 9px;
  font-size: 13px; font-family: 'Noto Sans KR', sans-serif; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-md);
  text-decoration: none;
}
.btn:hover { background: var(--surface2); border-color: var(--border2); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); color: #fff; }
.btn-sm { padding: 6px 13px; font-size: 12px; }

/* ── AI 선택 ── */
.ai-selector {
  display: flex; gap: 8px;
  padding: 12px 32px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}
.ai-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 18px; border-radius: 22px;
  border: 2px solid var(--border);
  background: transparent;
  font-size: 14px; font-family: 'Noto Sans KR', sans-serif;
  font-weight: 600; cursor: pointer; transition: all 0.15s;
  color: var(--text-md);
}
.ai-tab .ai-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ai-tab[data-ai="gemini"]  .ai-dot { background: #4285f4; }
.ai-tab[data-ai="claude"]  .ai-dot { background: #c8612a; }
.ai-tab[data-ai="chatgpt"] .ai-dot { background: #10a37f; }
.ai-tab:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }
.ai-tab.active { color: var(--text); border-color: var(--text); background: var(--surface2); }
.ai-tab[data-ai="gemini"].active  { border-color: #4285f4; background: #e8f0fe; color: #1a56c4; }
.ai-tab[data-ai="claude"].active  { border-color: #c8612a; background: #fef0e8; color: #b04a1a; }
.ai-tab[data-ai="chatgpt"].active { border-color: #10a37f; background: #e6f9f4; color: #0a7a5e; }
.ai-tab-lock { font-size: 11px; opacity: 0.6; }

/* ── CHAT ── */
#chat {
  flex: 1; overflow-y: auto;
  padding: 32px; display: flex; flex-direction: column;
  gap: 22px; scroll-behavior: smooth;
}
#chat::-webkit-scrollbar { width: 4px; }
#chat::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.msg { display: flex; gap: 12px; animation: fadeUp 0.25s ease both; }
.msg.user { flex-direction: row-reverse; }
@keyframes fadeUp { from{opacity:0;transform:translateY(7px);}to{opacity:1;transform:translateY(0);} }

.avatar {
  width: 34px; height: 34px; border-radius: 10px;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; margin-top: 2px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-md);
}
.msg.user .avatar { background: var(--accent-lt); border-color: #e0b0aa; color: var(--accent); font-size: 12px; }

.bubble {
  max-width: 70%; padding: 14px 18px;
  border-radius: 14px; font-size: 15px; font-weight: 400;
  line-height: 1.9; word-break: break-word; white-space: pre-wrap;
  border: 1.5px solid var(--border);
}
.msg.ai   .bubble { background: var(--surface); border-top-left-radius: 4px; color: var(--text); }
.msg.user .bubble { background: var(--accent-lt); border-color: #e0b0aa; border-top-right-radius: 4px; color: #7a1e14; font-weight: 500; }

.msg-meta {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px; letter-spacing: 0.04em;
}
.meta-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* 타이핑 */
.typing-dots { display:flex; gap:5px; align-items:center; padding:4px 0; }
.typing-dots span { width:7px; height:7px; border-radius:50%; background:var(--border2); animation:tdot 1.4s ease-in-out infinite; }
.typing-dots span:nth-child(2){animation-delay:.2s;}
.typing-dots span:nth-child(3){animation-delay:.4s;}
@keyframes tdot{0%,60%,100%{opacity:.3;transform:scale(.8);}30%{opacity:1;transform:scale(1.1);}}

/* ── 파일 업로드 영역 ── */
.upload-bar {
  padding: 10px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.upload-label {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 9px;
  border: 2px dashed var(--border2);
  background: var(--bg); color: var(--text-dim);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.upload-label:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }
#fileInput { display: none; }
.file-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-lt); border: 1.5px solid var(--green);
  color: var(--green); padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.file-badge .remove-file {
  cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--green); opacity: 0.7;
}
.file-badge .remove-file:hover { opacity: 1; }

/* ── INPUT ── */
.input-wrap {
  padding: 16px 32px 22px;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
}
.input-row {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 14px; padding: 11px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.09);
}
#inputBox {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 16px;
  font-family: 'Noto Sans KR', sans-serif; font-weight: 400;
  resize: none; max-height: 140px; min-height: 24px; line-height: 1.6;
}
#inputBox::placeholder { color: var(--text-dim); font-size: 15px; }
#sendBtn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
#sendBtn:hover { background: var(--accent-dk); transform: scale(1.04); }
#sendBtn:disabled { background: var(--border2); cursor: not-allowed; transform: none; }
#sendBtn svg { width: 16px; height: 16px; fill: #fff; }
.input-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.input-hint { font-size: 12px; font-weight: 500; color: var(--text-dim); }

/* ── WELCOME ── */
.welcome { margin: auto; text-align: center; padding: 48px 24px; max-width: 500px; }
.welcome-logo { margin-bottom: 20px; }
.welcome h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 28px; color: var(--text); margin-bottom: 10px; font-style: italic;
}
.welcome p { font-size: 15px; font-weight: 400; color: var(--text-dim); line-height: 2.0; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 24px; }
.quick-btn {
  padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: 11px; background: var(--surface);
  color: var(--text-md); font-size: 13px; font-weight: 500;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer; text-align: left; transition: all 0.15s; line-height: 1.5;
}
.quick-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }
.quick-btn .qb-icon { font-size: 18px; display: block; margin-bottom: 5px; }

/* ── 엔진 배지 ── */
.engine-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
}

/* ── 모바일 ── */
.sidebar-toggle {
  display: none; background: none; border: none;
  cursor: pointer; padding: 4px; color: var(--text-md);
}
@media(max-width:768px){
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.25); z-index:99; }
  .sidebar-overlay.show { display:block; }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  #chat { padding: 18px; gap: 18px; }
  .input-wrap { padding: 12px 18px 18px; }
  .ai-selector, .upload-bar { padding: 10px 18px; }
  .topbar { padding: 12px 18px; }
  .bubble { max-width: 87%; font-size: 15px; }
  .ai-tab { padding: 6px 13px; font-size: 13px; }
}

/* ── 글씨 크기 전면 강화 패치 ── */
body { font-size: 17px; }

.nav-item { font-size: 16px; padding: 12px 14px; }
.nav-icon  { font-size: 18px; }
.sidebar-section-label { font-size: 12px; }
.logo-text .ko { font-size: 20px; }
.logo-text .en { font-size: 12px; }

.topbar-title { font-size: 20px; }
.topbar-sub   { font-size: 14px; }
.btn     { font-size: 14px; padding: 9px 18px; }
.btn-sm  { font-size: 13px; padding: 7px 14px; }

.ai-tab  { font-size: 15px; padding: 8px 20px; }
.ai-dot  { width: 9px; height: 9px; }

.bubble  { font-size: 16px; line-height: 1.95; padding: 15px 20px; }
.msg-meta { font-size: 12px; }

#inputBox { font-size: 17px; }
#inputBox::placeholder { font-size: 16px; }
#sendBtn  { width: 42px; height: 42px; }
.input-hint { font-size: 13px; }

.upload-bar span { font-size: 13px !important; }
.upload-label { font-size: 14px; padding: 8px 18px; }
.file-badge { font-size: 13px; }

.welcome h2 { font-size: 30px; }
.welcome p  { font-size: 16px; }
.quick-btn  { font-size: 14px; padding: 13px 15px; }
.quick-btn .qb-icon { font-size: 20px; }

.engine-badge { font-size: 13px; padding: 5px 14px; }
.sidebar-footer-info { font-size: 13px; }

/* 엔진 카드 (홈) */
.engine-name { font-size: 17px; }
.engine-desc { font-size: 14px; }
.engine-tag  { font-size: 12px; }

@media(max-width:768px){
  .bubble   { font-size: 17px; max-width: 90%; }
  #inputBox { font-size: 17px; }
  .topbar-title { font-size: 18px; }
  .ai-tab { font-size: 14px; padding: 7px 14px; }
  .btn-sm { font-size: 13px; }
}
