:root {
  --crimson: #8d0c34;
  --crimson-dark: #6e0a29;
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #23201d;
  --muted: #8a8580;
  --line: #e6e2dc;
  --user-bubble: #f3e2e8;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* ── 헤더 ─────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--crimson);
  color: #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; }
header h1 { font-size: 17px; margin: 0; font-weight: 700; }
header .sub { font-size: 11.5px; opacity: .82; margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 10px; }
#model-select {
  background: rgba(0,0,0,.22);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  max-width: 190px;
  cursor: pointer;
}
#model-select:hover { background: rgba(0,0,0,.34); }
#model-select option { color: var(--ink); background: #fff; }
#model-select:disabled { opacity: .55; cursor: default; }
.mode-switch {
  display: flex;
  background: rgba(0,0,0,.22);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.mode-switch button {
  border: none;
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.mode-switch button.active {
  background: #fff;
  color: var(--crimson);
  font-weight: 700;
}
#new-chat {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
#new-chat:hover { background: rgba(255,255,255,.26); }

/* ── 대화 영역 ─────────────────── */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 22px 0 30px;
}
.row { max-width: 860px; margin: 0 auto 16px; padding: 0 18px; display: flex; }
.row.user { justify-content: flex-end; }
.bubble {
  max-width: 92%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.65;
  font-size: 14.5px;
  overflow-wrap: break-word;
}
.row.user .bubble {
  background: var(--user-bubble);
  border: 1px solid #e8cdd8;
  white-space: pre-wrap;
}
.row.assistant .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  width: 92%;
}
.bubble .user-imgs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.bubble .user-imgs img { max-height: 120px; max-width: 180px; border-radius: 8px; border: 1px solid #d9bdc9; }

/* 환영 화면 */
.welcome { max-width: 640px; margin: 8vh auto 0; text-align: center; padding: 0 20px; }
.welcome-icon { font-size: 46px; }
.welcome h2 { margin: 10px 0 8px; font-size: 22px; }
.welcome p { color: var(--muted); font-size: 14px; line-height: 1.7; }
.examples { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.example {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.example:hover { border-color: var(--crimson); color: var(--crimson); }

/* ── 생각/도구/인용 ─────────────── */
details.reasoning {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
  background: #faf8f5;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
details.reasoning summary { cursor: pointer; user-select: none; font-weight: 600; }
details.reasoning .r-body {
  margin-top: 6px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.55;
}
.toolchips { display: flex; flex-direction: column; gap: 5px; margin: 0 0 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: #5c5650;
  background: #f4f1ec;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  width: fit-content;
  max-width: 100%;
}
.chip .spin {
  width: 11px; height: 11px;
  border: 2px solid #cfc8bf;
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chip.done .spin { display: none; }
.chip .ok { display: none; color: #2c7a39; font-weight: 700; }
.chip.done .ok { display: inline; }
.cites { margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--line); }
.cites .cites-title { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.cites .cite-list { display: flex; flex-wrap: wrap; gap: 5px; }
.cite {
  font-size: 12px;
  background: #f7ecf0;
  color: var(--crimson-dark);
  border: 1px solid #e5c7d2;
  border-radius: 7px;
  padding: 3px 8px;
}
a.cite {
  text-decoration: none;
  background: #eef3f8;
  color: #1c4f82;
  border-color: #c8d8e8;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.cite:hover { border-color: #1c4f82; }
.error-box {
  color: #a3251e;
  background: #fdf1f0;
  border: 1px solid #f0c9c6;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  margin-top: 8px;
}
.cursor { display: inline-block; width: 7px; height: 15px; background: var(--crimson); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── 마크다운 콘텐츠 ────────────── */
.md h1, .md h2, .md h3 { margin: 14px 0 6px; line-height: 1.4; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16.5px; } .md h3 { font-size: 15px; }
.md p { margin: 7px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--crimson); background: #faf6f4; color: #5f5a55; border-radius: 0 6px 6px 0; }
.md code { background: #f2efe9; border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.md pre { background: #f2efe9; border-radius: 8px; padding: 10px; overflow-x: auto; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.md .tbl-wrap { overflow-x: auto; margin: 8px 0; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 40%; }
.md th, .md td { border: 1px solid #d8d2ca; padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: #f4ede7; font-weight: 700; }
.md tr:nth-child(even) td { background: #fbf9f6; }
.md a { color: var(--crimson); }
.md .math-block { display: block; overflow-x: auto; padding: 2px 0; }
.md .katex-display { margin: 10px 0; }
.md .katex { font-size: 1.06em; }

/* ── 입력 영역 ─────────────────── */
footer {
  flex-shrink: 0;
  background: linear-gradient(transparent, var(--bg) 30%);
  padding: 4px 18px 10px;
}
#thumbs { max-width: 820px; margin: 0 auto; display: flex; gap: 8px; flex-wrap: wrap; }
#thumbs:not(:empty) { margin-bottom: 2px; }
#thumbs .thumb { position: relative; animation: thumb-in .18s ease-out; }
#thumbs img {
  height: 58px; border-radius: 8px; border: 1px solid var(--line);
  display: block; object-fit: cover;
}
@keyframes thumb-in {
  from { opacity: 0; transform: translateY(6px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
#thumbs .rm {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px;
  background: #3a3733; color: #fff;
  border: none; border-radius: 50%;
  font-size: 11px; line-height: 1;
  cursor: pointer;
}
.composer {
  max-width: 820px;
  margin: 6px auto 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.composer:focus-within { border-color: var(--crimson); }
#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 150px;
  background: transparent;
}
#attach, #send {
  border: none;
  background: none;
  font-size: 19px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 9px;
  flex-shrink: 0;
}
#attach:hover { background: #f2efe9; }
#send { background: var(--crimson); color: #fff; }
#send:hover { background: var(--crimson-dark); }
#send.stop { background: #3a3733; }
#send:disabled { background: #cfc8bf; cursor: default; }
/* ── 드래그&드롭 ───────────────── */
.composer.dragging { border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(141,12,52,.12); }

#dropzone {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(40, 36, 33, .34);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: dz-fade .14s ease-out;
}
#dropzone.on { display: grid; }
@keyframes dz-fade { from { opacity: 0; } to { opacity: 1; } }

.dz-card {
  background: var(--card);
  border: 2.5px dashed var(--crimson);
  border-radius: 18px;
  padding: 34px 46px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  animation: dz-pop .18s cubic-bezier(.2,.9,.3,1.2);
  pointer-events: none;
}
@keyframes dz-pop {
  from { opacity: 0; transform: scale(.93); }
  to   { opacity: 1; transform: none; }
}
.dz-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.dz-title { font-weight: 700; font-size: 16.5px; color: var(--crimson); }
.dz-sub { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* 텍스트 전용 모델일 때 거부 상태 */
#dropzone.deny .dz-card { border-color: #b9b3ab; }
#dropzone.deny .dz-title { color: #3a3733; }

/* ── 토스트 ────────────────────── */
#toast {
  position: fixed;
  left: 50%;
  top: 74px;                    /* 헤더 바로 아래 — 썸네일/입력창과 겹치지 않게 */
  transform: translate(-50%, -8px);
  z-index: 70;
  max-width: min(90vw, 460px);
  background: #3a3733;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  padding: 9px 15px;
  border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

.notice { max-width: 820px; margin: 7px auto 0; text-align: center; font-size: 11px; color: var(--muted); }

/* ── 레이아웃(사이드바 + 본문) ──────── */
#layout { display: flex; flex: 1; min-height: 0; }
#main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#sidebar {
  width: 258px;
  flex-shrink: 0;
  background: #17140f;
  color: #ece7e0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #000;
}
.sb-top { padding: 12px 12px 8px; }
.sb-new {
  width: 100%;
  background: transparent;
  color: #ece7e0;
  border: 1px solid #4b443c;
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.sb-new:hover { background: #241f18; border-color: #6d6357; }

.sb-list { flex: 1; overflow-y: auto; padding: 4px 8px 10px; overscroll-behavior: contain; }

/* ── 스크롤바 ─────────────────────
   기본 스크롤바가 어두운 사이드바와 따로 놀아서 배경에 맞춘다.
   평소엔 거의 안 보이다가 영역에 마우스를 올리면 드러난다.
   (border + background-clip 조합으로 막대 양옆에 여백을 만든 것) */
.sb-list::-webkit-scrollbar { width: 10px; }
.sb-list::-webkit-scrollbar-track { background: transparent; }
.sb-list::-webkit-scrollbar-thumb {
  background: #2f2820;
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
.sb-list:hover::-webkit-scrollbar-thumb { background: #4d4438; background-clip: padding-box; }
.sb-list::-webkit-scrollbar-thumb:hover { background: #6b6053; background-clip: padding-box; }
.sb-list { scrollbar-width: thin; scrollbar-color: #3a332b transparent; }  /* Firefox */

#chat::-webkit-scrollbar { width: 12px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb {
  background: #ded8cf;
  border-radius: 99px;
  border: 4px solid transparent;
  background-clip: padding-box;
}
#chat::-webkit-scrollbar-thumb:hover { background: #c3bbae; background-clip: padding-box; }
#chat { scrollbar-width: thin; scrollbar-color: #ded8cf transparent; }

/* 생각 과정 패널·표 등 작은 스크롤 영역 */
.r-body::-webkit-scrollbar, .md .tbl-wrap::-webkit-scrollbar,
.md pre::-webkit-scrollbar { width: 9px; height: 9px; }
.r-body::-webkit-scrollbar-track, .md .tbl-wrap::-webkit-scrollbar-track,
.md pre::-webkit-scrollbar-track { background: transparent; }
.r-body::-webkit-scrollbar-thumb, .md .tbl-wrap::-webkit-scrollbar-thumb,
.md pre::-webkit-scrollbar-thumb {
  background: #d3ccc2;
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.r-body::-webkit-scrollbar-thumb:hover, .md .tbl-wrap::-webkit-scrollbar-thumb:hover,
.md pre::-webkit-scrollbar-thumb:hover { background: #b3aa9d; background-clip: padding-box; }
.sb-group { font-size: 11px; color: #8b8177; padding: 12px 8px 5px; }
.conv {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  padding: 8px 8px 8px 10px;
  cursor: pointer;
  color: #d6cfc6;
  font-size: 13.5px;
}
.conv:hover { background: #241f18; }
.conv.active { background: #322a20; color: #fff; }
.conv .t {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv .menu {
  border: none;
  background: none;
  color: #9a9086;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0;
}
.conv:hover .menu, .conv.active .menu { opacity: 1; }
.conv .menu:hover { background: #443b2f; color: #fff; }
.sb-empty { color: #8b8177; font-size: 12.5px; padding: 14px 10px; line-height: 1.6; }

.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #2c261f;
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sb-user:hover { background: #241f18; }
.sb-caret { color: #8b8177; font-size: 11px; }
.sb-avatar {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--crimson);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
}
.sb-username { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ── 설정 창 ─────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(20,17,13,.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  padding: 20px 22px 22px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
  background: none; border: none; font-size: 17px; color: var(--muted);
  cursor: pointer; padding: 4px 6px; border-radius: 7px; line-height: 1;
}
.modal-close:hover { background: #f2efe9; color: var(--ink); }

.modal-tabs { display: flex; gap: 4px; margin: 16px 0 4px; border-bottom: 1px solid var(--line); }
.modal-tabs .tab {
  background: none; border: none; font: inherit; font-size: 13.5px;
  color: var(--muted); padding: 8px 12px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.modal-tabs .tab.active { color: var(--crimson); border-bottom-color: var(--crimson); font-weight: 700; }

.tab-body { padding-top: 14px; }
.tab-body[hidden] { display: none; }
.tab-body label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; }
.tab-body input[type=password], .tab-body input[type=text] {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 11px;
  border: 1.5px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink);
}
.tab-body input:focus { outline: none; border-color: var(--crimson); }
.tab-body .hint { font-size: 12.5px; color: var(--muted); line-height: 1.65; margin: 0 0 12px; }
.tab-body .hint code { background: #f2efe9; border-radius: 4px; padding: 1px 5px; }

button.primary {
  width: 100%; margin-top: 16px; background: var(--crimson); color: #fff;
  border: none; border-radius: 9px; padding: 11px; font: inherit;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
button.primary:hover { background: var(--crimson-dark); }
button.primary:disabled { background: #cfc8bf; cursor: default; }

.form-msg {
  margin-top: 12px; border-radius: 8px; padding: 9px 11px; font-size: 13px;
  background: #fdf1f0; border: 1px solid #f0c9c6; color: #a3251e;
}
.form-msg.ok { background: #f0f7f1; border-color: #c6e0cb; color: #2c7a39; }

.code-row {
  display: flex; align-items: center; gap: 6px;
  background: #f7f5f1; border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 8px 8px 11px; margin-bottom: 10px;
}
.code-row code {
  flex: 1; font-size: 12.5px; overflow-x: auto; white-space: nowrap;
  color: var(--ink); background: none; padding: 0;
}
.copy {
  flex-shrink: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 10px; font: inherit; font-size: 12px;
  cursor: pointer; color: var(--ink);
}
.copy:hover { border-color: var(--crimson); color: var(--crimson); }
.copy.done { background: #f0f7f1; border-color: #c6e0cb; color: #2c7a39; }

.key-alert {
  background: #fff8e6; border: 1px solid #f0e0b0; color: #7a5d16;
  border-radius: 8px; padding: 8px 11px; font-size: 12.5px; margin-bottom: 8px;
}
.key-list { margin-top: 6px; }
.key-item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; margin-bottom: 7px; font-size: 13px;
}
.key-item .k { flex: 1; min-width: 0; }
.key-item .k code { font-size: 12.5px; background: none; padding: 0; }
.key-item .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.key-item .del {
  background: none; border: 1px solid var(--line); border-radius: 7px;
  color: #a3251e; padding: 4px 9px; font: inherit; font-size: 12px; cursor: pointer;
}
.key-item .del:hover { background: #fdf1f0; border-color: #f0c9c6; }
.key-empty { color: var(--muted); font-size: 12.5px; padding: 6px 2px 2px; }

.usage { margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.usage summary { cursor: pointer; }
.usage pre {
  margin-top: 8px; background: #f7f5f1; border: 1px solid var(--line);
  border-radius: 9px; padding: 11px; overflow-x: auto; font-size: 12px;
  color: var(--ink); line-height: 1.6;
}

/* 대화 항목 컨텍스트 메뉴 */
.ctx-menu {
  position: fixed;
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 6px 22px rgba(0,0,0,.18);
  padding: 4px;
  min-width: 132px;
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}
.ctx-menu button:hover { background: #f2efe9; }
.ctx-menu button.danger { color: #a3251e; }
.ctx-menu button.danger:hover { background: #fdf1f0; }

/* 헤더의 목록 토글 — 넓은 화면에서도 항상 보이는 확실한 조작 수단 */
#sb-toggle {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 7px 10px;
  margin-right: 4px;
  border-radius: 8px;
}
#sb-toggle:hover { background: rgba(255,255,255,.26); }
#sb-backdrop { display: none; }

/* 사이드바 접기 — 가장자리에 붙어 있는 플로팅 핸들 */
#sidebar { transition: margin-left .22s ease; }
body.sb-collapsed #sidebar { margin-left: -258px; }

#sb-float {
  position: fixed;
  left: 258px;
  top: 50%;
  z-index: 45;
  width: 26px;
  height: 72px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 9px 9px 0;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: .65;
  box-shadow: 2px 0 10px rgba(0,0,0,.07);
  transition: left .22s ease, opacity .15s ease, background .15s ease, color .15s ease;
}
#sb-float:hover { opacity: 1; background: #f2efe9; color: var(--ink); }
/* 접었을 때는 이게 다시 펴는 유일한 단서라 더 잘 보이게 둔다 */
body.sb-collapsed #sb-float { left: 0; opacity: .8; color: var(--crimson); }
body.sb-collapsed #sb-float:hover { opacity: 1; }

/* ── 로그인 화면 ─────────────────── */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 370px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 30px 26px;
  box-shadow: 0 6px 26px rgba(0,0,0,.07);
  text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 19px; margin: 8px 0 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; }
.login-card input {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--crimson); }
#login-btn {
  width: 100%;
  margin-top: 20px;
  background: var(--crimson);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 11px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
#login-btn:hover { background: var(--crimson-dark); }
#login-btn:disabled { background: #cfc8bf; cursor: default; }
.login-error {
  margin-top: 14px;
  background: #fdf1f0;
  border: 1px solid #f0c9c6;
  color: #a3251e;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
}
.login-foot { color: var(--muted); font-size: 11.5px; margin: 20px 0 0; }

@media (max-width: 640px) {
  .row { margin-bottom: 12px; }
  .bubble { font-size: 14px; }
  header { padding: 8px 10px; }
  header h1 { font-size: 15px; }
  header .sub { display: none; }
  .logo { display: none; }
  .mode-switch button { padding: 5px 7px; font-size: 11px; }
  .welcome { margin-top: 4vh; }

  /* 좁은 화면에서는 서랍 방식(헤더 ☰)을 쓰고 플로팅 핸들은 숨긴다 */
  #sb-float { display: none; }
  #sb-toggle { padding: 5px 8px; font-size: 15px; }
  body.sb-collapsed #sidebar { margin-left: 0; }
  #sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  body.sb-open #sidebar { transform: none; }
  body.sb-open #sb-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0,0,0,.42);
  }
}
