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

:root {
  --bg:        #0d0f12;
  --surface:   #13161b;
  --surface2:  #1a1e25;
  --border:    #232830;
  --accent:    #e8c547;
  --accent2:   #5b8af0;
  --text:      #d4d8e0;
  --text-dim:  #5a6070;
  --text-mid:  #8a909e;
  --danger:    #e05454;
  --green:     #4caf82;
  --radius:    10px;
  --font-mono: 'DM Mono', monospace;
  --font-sans: 'DM Sans', sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-sans); }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -1px;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.item-list { display: flex; flex-direction: column; gap: 6px; }

.sidebar-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.sidebar-item .item-title {
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item .item-meta {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.item-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  margin-top: 3px;
}

.badge-soon { background: rgba(232, 197, 71, 0.15); color: var(--accent); }
.badge-ok   { background: rgba(76, 175, 130, 0.12); color: var(--green); }

.empty-state {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-style: italic;
  padding: 2px 0;
}

.loading-line {
  height: 32px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: rgba(232, 197, 71, 0.08);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
}

.action-btn:hover { background: rgba(232, 197, 71, 0.16); }

.action-btn.secondary {
  border-color: var(--border);
  background: transparent;
  color: var(--text-dim);
}

.action-btn.secondary:hover { background: var(--surface2); color: var(--text-mid); }

/* ── Chat Area ───────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

.date-display { margin-left: auto; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.message { display: flex; max-width: 80%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.message.user .bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
  color: var(--text);
}

.message.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.bubble ul { margin: 8px 0 8px 18px; }
.bubble li { margin-bottom: 4px; }
.bubble strong { color: var(--accent); font-weight: 500; }
.bubble code { font-family: var(--font-mono); font-size: 0.82rem; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

.hint {
  color: var(--accent2);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.typing-indicator .bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}

.typing-dot {
  width: 6px; height: 6px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input Area ──────────────────────────────── */
.input-area {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  position: relative;
}

.saved-toast {
  background: rgba(76, 175, 130, 0.12);
  border: 1px solid rgba(76, 175, 130, 0.25);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  animation: fadeIn 0.2s ease;
}

.saved-toast.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 10px 14px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  max-height: 120px;
  overflow-y: auto;
}

textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--text-dim); }

.send-btn {
  width: 40px; height: 40px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #0d0f12;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.send-btn:hover { background: #f0d060; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar {
    display: none;
  }

  .chat-area { width: 100%; }
  .messages { padding: 16px 12px; }
  .message { max-width: 95%; }
  .input-area { padding: 12px; }
}
