:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8e9ec;
  --muted: #8a8f9c;
  --accent: #d97757;
  --accent-hover: #c96a4c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Pretendard, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---- Login ---- */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-box .sub { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login-box input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}
.login-box button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}
.login-box button:hover { background: var(--accent-hover); }
.error { color: #e5484d; font-size: 13px; min-height: 16px; margin: 0; }

/* ---- App shell ---- */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 16px; padding: 8px 8px 16px; }
.nav-item {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 4px;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--panel-2); color: var(--accent); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
}
.ghost-btn:hover { color: var(--text); border-color: var(--muted); }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

/* ---- Chat ---- */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg { max-width: 70%; padding: 10px 14px; border-radius: 12px; line-height: 1.5; font-size: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 2px; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.msg.assistant.pending { color: var(--muted); font-style: italic; }
.msg.assistant.error { border-color: #e5484d; color: #ff8a8a; }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  max-height: 160px;
}
.chat-input-row button {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  padding: 0 20px;
  font-weight: 600;
  font-size: 14px;
}
.chat-input-row button:hover { background: var(--accent-hover); }
.chat-input-row button:disabled { opacity: 0.5; cursor: default; }

/* ---- Notes ---- */
.note-input-row { display: flex; gap: 10px; padding: 20px 24px 8px; }
.note-input-row input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.note-input-row button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 0 16px;
  font-weight: 600;
}
.notes-list { list-style: none; margin: 0; padding: 8px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.note-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.note-item .note-text { white-space: pre-wrap; }
.note-item .note-del { background: transparent; border: none; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.note-item .note-del:hover { color: #e5484d; }
