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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
}

/* Navigation */
#nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: #111;
  border-bottom: 1px solid #222;
}

.nav-brand {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.nav-links { display: flex; gap: 4px; }

.nav-btn {
  background: none;
  border: none;
  color: #888;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.nav-btn:hover { color: #ccc; background: #1a1a1a; }
.nav-btn.active { color: #fff; background: #222; }

/* Views */
.view { display: none; padding: 24px; max-width: 1200px; margin: 0 auto; }
.view.active { display: block; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed #333;
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 32px;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: #4a9eff;
  color: #4a9eff;
  background: #0d1520;
}

/* Book List */
.book-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.book-card:hover { border-color: #333; }

.book-info h3 { font-size: 16px; color: #fff; margin-bottom: 4px; }
.book-info span { font-size: 13px; color: #666; }

.book-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-pending { background: #1a1a0a; color: #998; }
.status-ingesting { background: #0a1a2a; color: #4a9eff; }
.status-ready { background: #0a1a0a; color: #4aff4a; }
.status-error { background: #2a0a0a; color: #ff4a4a; }

.book-actions { display: flex; gap: 8px; align-items: center; }

.book-actions button {
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.book-actions button:hover { color: #fff; border-color: #666; }
.book-actions .delete-btn:hover { color: #ff4a4a; border-color: #ff4a4a; }

/* Graph */
#view-graph { position: relative; padding: 0; height: calc(100vh - 56px); }
#graph-container { width: 100%; height: 100%; }

#node-inspector {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 360px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  background: #111;
  border: 1px solid #222;
  border-radius: 12px;
  padding: 20px;
}

#node-inspector.hidden { display: none; }
#close-inspector { float: right; background: none; border: none; color: #666; font-size: 20px; cursor: pointer; }

#inspector-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.concept-tag {
  background: #1a1a2a;
  color: #4a9eff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

#inspector-content {
  font-size: 13px;
  line-height: 1.6;
  color: #aaa;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* Chat */
#view-chat {
  display: none;
  flex-direction: column;
  padding: 0;
  height: calc(100vh - 56px);
}

#view-chat.active { display: flex; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.chat-msg {
  margin-bottom: 16px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.chat-msg.user { text-align: right; }
.chat-msg.user .msg-content {
  background: #1a2a1a;
  border-radius: 12px 12px 4px 12px;
  padding: 12px 16px;
  display: inline-block;
  text-align: left;
}

.chat-msg.assistant .msg-content {
  background: #111;
  border: 1px solid #222;
  border-radius: 12px 12px 12px 4px;
  padding: 16px;
  line-height: 1.6;
}

.msg-sources {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-tag {
  background: #1a1a2a;
  color: #4a9eff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  background: #111;
  border-top: 1px solid #222;
}

#chat-model {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
}

#chat-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

#chat-input:focus { border-color: #4a9eff; }

#chat-send {
  background: #4a9eff;
  border: none;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

#chat-send:hover { background: #3a8eef; }

/* Settings */
.settings-form {
  max-width: 480px;
}

.settings-form label {
  display: block;
  margin: 16px 0 6px;
  font-size: 14px;
  color: #888;
}

.settings-form input {
  width: 100%;
  background: #111;
  border: 1px solid #333;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.settings-form input:focus { border-color: #4a9eff; }

#save-settings {
  margin-top: 20px;
  background: #4a9eff;
  border: none;
  color: #fff;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

#settings-status {
  margin-top: 12px;
  font-size: 13px;
  color: #4aff4a;
}

/* Utility */
.hidden { display: none !important; }
