* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Helvetica Neue", Arial, sans-serif;
  background: #ffffff;
  color: #0d0d0d;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: #6e6e80; font-size: 13px; line-height: 1.5; }
.error { color: #ef4146; font-size: 13px; margin-top: 8px; }

/* === TODOLIST (메인 위장 화면) === */
.todo-app {
  max-width: 640px;
  margin: 7vh auto 0;
  padding: 32px 24px 24px;
}
.todo-header {
  margin-bottom: 28px;
}
.todo-header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.todo-header .muted {
  font-size: 14px;
}
.todo-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.todo-input-row input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #d0d0d8;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: #0d0d0d;
}
.todo-input-row input:focus { outline: none; border-color: #0d0d0d; }
.todo-input-row button {
  width: 44px;
  height: 44px;
  background: #0d0d0d;
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  transition: background 0.15s;
}
.todo-input-row button:hover { background: #1f1f1f; }

.todo-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.todo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  transition: background 0.12s;
}
.todo-item:hover { background: #f7f7f9; }
.todo-item.done .todo-text {
  text-decoration: line-through;
  color: #9a9aa6;
}
.todo-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #0d0d0d;
  cursor: pointer;
  flex-shrink: 0;
}
.todo-text {
  flex: 1;
  font-size: 15px;
  word-break: break-word;
}
.todo-delete {
  background: none;
  border: 0;
  color: #c0c0c8;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}
.todo-item:hover .todo-delete { opacity: 1; }
.todo-delete:hover { color: #ef4146; }

.todo-empty {
  text-align: center;
  padding: 40px 0;
  color: #9a9aa6;
  font-size: 14px;
}
.todo-empty.hidden { display: none; }

.todo-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #ececec;
}
.secret-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4146;
  opacity: 0.35;
  cursor: default;
  transition: opacity 0.15s;
}
.secret-dot:hover { opacity: 0.45; }

/* === 로그인 화면 === */
.auth {
  max-width: 400px;
  margin: 14vh auto;
  padding: 32px 24px;
  text-align: center;
}
.auth h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.auth .muted { margin-bottom: 24px; }
.auth input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d0d0d8;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
}
.auth input:focus { outline: none; border-color: #0d0d0d; }
.auth button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: #0d0d0d;
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.auth button:hover { background: #1f1f1f; }

/* === 앱 레이아웃 === */
.app { display: flex; height: 100vh; }

/* === 사이드바 === */
.sidebar {
  width: 260px;
  background: #f9f9f9;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #ececec;
  overflow: hidden;
}
.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: #0d0d0d;
  font-family: inherit;
}
.new-chat:hover { background: #ececec; }
.plus { font-size: 16px; line-height: 1; }

.history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 12px;
  padding: 0 4px;
}
.hist-section {
  font-size: 12px;
  color: #8e8ea0;
  padding: 12px 8px 6px;
  font-weight: 500;
}
.hist-item {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #0d0d0d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-item:hover { background: #ececec; }
.hist-item.active { background: #ececec; }

.sidebar-footer {
  border-top: 1px solid #ececec;
  padding: 12px 4px 4px;
  margin-top: 8px;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.user-row:hover { background: #ececec; }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5436DA, #8E5BFF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* === 메인 영역 === */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid #f0f0f2;
  height: 56px;
}
.model-name {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}
.model-name:hover { background: #f4f4f4; }
.model-version { color: #6e6e80; font-weight: 400; font-size: 15px; }
.caret { color: #8e8ea0; margin-left: 2px; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d0d0d8;
}
.status-dot.connected { background: #10A37F; }
.status-dot.disconnected { background: #ef4146; }

/* === 메시지 영역 === */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}
.message {
  max-width: 768px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  gap: 16px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.avatar.user { background: linear-gradient(135deg, #5436DA, #8E5BFF); }
.avatar.bot { background: #0d0d0d; }
.avatar.bot svg { color: #fff; }

.content {
  flex: 1;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #0d0d0d;
  padding-top: 3px;
}
.message.status .content {
  color: #b91c1c;
  font-size: 13px;
  padding: 10px 14px;
  background: #fef2f2;
  border-radius: 10px;
  border: 1px solid #fecaca;
}

/* === 입력 영역 === */
.composer-wrap {
  padding: 0 24px 12px;
  background: #fff;
}
.composer {
  max-width: 768px;
  margin: 0 auto;
  position: relative;
}
.composer textarea {
  width: 100%;
  resize: none;
  padding: 14px 50px 14px 18px;
  background: #fff;
  border: 1px solid #d0d0d8;
  border-radius: 28px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.composer textarea:focus { outline: none; border-color: #0d0d0d; }
.composer textarea::placeholder { color: #8e8ea0; }

.send-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0d0d0d;
  color: #fff;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.send-btn:hover { background: #1f1f1f; }
.send-btn:disabled { background: #d0d0d8; cursor: not-allowed; }

.footnote {
  text-align: center;
  font-size: 12px;
  color: #8e8ea0;
  margin-top: 10px;
}

/* === 반응형 === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .message { padding: 14px 16px; }
  .composer-wrap { padding: 0 16px 8px; }
  .messages { padding: 16px 0; }
}

/* === 이미지 첨부 === */
.composer-wrap { position: relative; }
.composer-wrap.drag-over::before {
  content: '이미지를 여기에 놓으세요';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 13, 0.04);
  border: 2px dashed #0d0d0d;
  border-radius: 12px;
  font-size: 13px;
  color: #0d0d0d;
  pointer-events: none;
  z-index: 5;
}
.img-preview {
  max-width: 768px;
  margin: 0 auto 8px;
}
.img-preview-chip {
  position: relative;
  display: inline-block;
  background: #f4f4f4;
  border-radius: 12px;
  padding: 6px;
}
.img-preview-chip img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 8px;
  display: block;
}
.img-preview-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0d0d0d;
  color: #fff;
  border: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.img-preview-x:hover { background: #1f1f1f; }
.msg-img {
  max-width: 320px;
  max-height: 320px;
  border-radius: 10px;
  display: block;
}

/* === 스크롤바 (ChatGPT 스타일) === */
.messages::-webkit-scrollbar, .history::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .history::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}
.messages::-webkit-scrollbar-thumb:hover, .history::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}
.messages::-webkit-scrollbar-track, .history::-webkit-scrollbar-track {
  background: transparent;
}

/* === 새 메시지 배지 === */
.new-msg-badge {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #10a37f;
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 50;
}
.new-msg-badge:hover {
  background: #0d8a6a;
}
.new-msg-badge.hidden { display: none; }

/* === 파일 첨부 칩 === */
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  margin-top: 4px;
  max-width: 360px;
  transition: background 0.15s;
}
.file-chip:hover {
  background: rgba(0, 0, 0, 0.08);
}
.file-chip-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  background: #10a37f;
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-chip-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.file-chip-name {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip-sub {
  font-size: 12px;
  opacity: 0.65;
  margin-top: 2px;
}
