body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: #f8f9fa; margin: 0; }
.auth-container { max-width: 420px; margin: 80px auto; background: #fff; padding: 24px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.auth-container h2 { margin: 0 0 16px 0; color: #343a40; font-weight: 600; text-align: center; }
.auth-card { display: flex; flex-direction: column; gap: 10px; }
.auth-card label { font-size: 0.9rem; color: #495057; }
.auth-card input { padding: 10px 12px; border: 1px solid #ced4da; border-radius: 8px; font-size: 1rem; }
.auth-card button { padding: 12px 16px; border: none; border-radius: 10px; font-weight: 500; cursor: pointer; }
.auth-card button.secondary { background: #e9ecef; color: #495057; }
.auth-card button:not(.secondary) { background: #007bff; color: #fff; }
.auth-card button:hover { opacity: 0.95; }
.auth-card .muted { color: #6c757d; font-size: 0.9rem; margin-top: 6px; } 

/* Chat page base */
body { display: flex; flex-direction: column; align-items: center; height: 100vh; overflow: hidden; }

/* App container */
#app-container { display: flex; flex-direction: row; width: 100%; max-width: 1200px; height: calc(100vh - 120px); box-sizing: border-box; background-color: #ffffff; box-shadow: 0 4px 12px rgba(0,0,0,0.05); border-radius: 12px; overflow: hidden; margin: 24px; }

/* Sidebar */
#topics-sidebar { width: 280px; background-color: #f8f9fa; border-right: 1px solid #e9ecef; padding: 20px; overflow-y: auto; flex-shrink: 0; }
#topics-sidebar h3 { font-size: 1.1rem; font-weight: 600; color: #495057; margin: 0 0 15px 0; padding-bottom: 10px; border-bottom: 2px solid #007bff; }
.student-info { background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%); border-radius: 8px; padding: 12px; margin-bottom: 20px; font-size: 0.9rem; color: #37474f; }
.student-info strong { color: #1565c0; }
.topics-list { list-style: none; padding: 0; margin: 0; }
.topic-item { background: #ffffff; border: 1px solid #e9ecef; border-radius: 6px; padding: 12px 16px; margin-bottom: 10px; font-size: 0.85rem; color: #495057; transition: all 0.2s ease; cursor: pointer; }
.topic-name { font-weight: 500; margin-bottom: 4px; color: #343a40; }
.topic-description { font-size: 0.8rem; color: #6c757d; line-height: 1.4; white-space: pre-line; background: #f8f9fa; padding: 8px; border-radius: 4px; border-left: 3px solid #007bff; margin-top: 8px; }
.topic-item:hover { background: #f0f8ff; border-color: #007bff; transform: translateX(2px); }
.topic-item::before { content: "📝"; margin-right: 8px; }
.topic-item.active { background: #e3f2fd; border-color: #007bff; color: #00529b; font-weight: 500; transform: translateX(4px); box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15); }
.topic-item.active::before { content: "✅"; margin-right: 8px; }

/* Main chat area */
#chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
#chat-container { flex: 1; display: flex; flex-direction: column; padding: 28px 32px 16px 32px; overflow-y: auto; box-sizing: border-box; min-height: 0; max-height: 100%; }
.message { padding: 12px 18px; border-radius: 18px; margin-bottom: 12px; max-width: 85%; line-height: 1.5; font-size: 1.08rem; }
.user { align-self: flex-end; background-color: #e0f0ff; color: #00529b; }
.assistant { align-self: flex-start; background-color: #f1f3f5; color: #343a40; border: none; }

/* Assistant markdown */
.assistant p { margin: 0.5em 0; color: #334155; line-height: 1.6; white-space: pre-wrap; }
.assistant ul, .assistant ol { margin: 0.5em 0 0.5em 20px; padding: 0; color: #334155; }
.assistant li { margin-bottom: 0.25em; color: #334155; }
.assistant pre { background-color: #1e293b; color: #e2e8f0; padding: 18px; border-radius: 8px; overflow-x: auto; font-size: 1em; border: 1px solid #475569; margin: 1em 0; }
.assistant code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 1em; background-color: #f1f5f9; color: #dc2626; padding: 2px 6px; border-radius: 4px; border: 1px solid #e2e8f0; }
.assistant pre code { background-color: transparent; color: inherit; padding: 0; border-radius: 0; border: none; }
.assistant h1 { font-size: 1.7rem; font-weight: bold; margin: 1em 0 0.5em 0; padding: 14px 18px; background: linear-gradient(135deg, #dbeafe 0%, transparent 100%); border-bottom: 2px solid #3b82f6; border-radius: 8px 8px 0 0; color: #1e40af; }
.assistant h2 { font-size: 1.35rem; font-weight: bold; margin: 0.8em 0 0.4em 0; padding: 10px 14px; background: linear-gradient(135deg, #ecfdf5 0%, transparent 100%); border-bottom: 1px solid #10b981; border-radius: 6px 6px 0 0; color: #065f46; }
.assistant h3 { font-size: 1.18rem; font-weight: bold; margin: 0.6em 0 0.3em 0; padding: 8px 12px; background: linear-gradient(135deg, #faf5ff 0%, transparent 100%); border-left: 4px solid #8b5cf6; border-radius: 0 4px 4px 0; color: #5b21b6; }
.assistant h4 { font-size: 1.08rem; font-weight: 600; margin: 0.5em 0 0.25em 0; padding-left: 14px; border-left: 2px solid #f97316; color: #ea580c; }
.assistant em { font-style: italic; color: #1e293b; font-weight: 500; }
.assistant strong { font-weight: 600; color: #1e293b; }
.assistant blockquote { margin: 1em 0; padding: 14px 18px; background: linear-gradient(135deg, #fef3c7 0%, transparent 100%); border-left: 4px solid #f59e0b; border-radius: 0 8px 8px 0; color: #92400e; font-style: italic; }

/* Improved math display - more compact for simple expressions */
.katex-display { 
  margin: 0.8em 0 !important; 
  padding: 8px 12px; 
  background: linear-gradient(135deg, #f8fafc 0%, transparent 100%); 
  border: 1px solid #e2e8f0; 
  border-radius: 6px; 
  text-align: center; 
}

/* Make very simple math expressions even more compact */
.katex-display .katex .base:only-child {
  margin: 0;
}

/* Better inline math styling */
.katex { font-size: 1.1em; color: #1e293b; }
.katex-inline { 
  color: #dc2626; 
  font-weight: 500; 
  background: #fef2f2; 
  padding: 2px 4px; 
  border-radius: 3px; 
  border: 1px solid #fecaca; 
}
.assistant img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin: 1em 0; border: 1px solid #e2e8f0; display: block; margin-left: auto; margin-right: auto; }
.image-container { text-align: center; margin: 1.5em 0; padding: 16px; background: linear-gradient(135deg, #f8fafc 0%, transparent 100%); border-radius: 12px; border: 1px solid #e2e8f0; }
.image-container img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.image-caption { margin-top: 8px; font-size: 0.9em; color: #64748b; font-style: italic; }

/* Tool calls */
.tool-calls-container { margin: 16px 0; background: #f8fafc; border-radius: 6px; font-size: 0.9em; overflow: hidden; }
.tool-calls-header { display: flex; align-items: center; cursor: pointer; font-weight: 500; color: #64748b; padding: 12px 16px; user-select: none; background: #f1f5f9; }
.tool-calls-header:hover { background: #e2e8f0; }
.tool-calls-toggle { margin-right: 8px; font-size: 12px; transition: transform 0.15s ease; }
.tool-calls-toggle.expanded { transform: rotate(90deg); }
.tool-calls-content { display: none; padding: 16px; }
.tool-calls-content.expanded { display: block; }
.tool-call-item { margin-bottom: 16px; }
.tool-call-item:last-child { margin-bottom: 0; }
.tool-call-name { font-weight: 600; color: #374151; margin-bottom: 8px; font-size: 0.9em; }
.tool-call-args { font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace; font-size: 0.8em; color: #4b5563; background: #ffffff; padding: 12px; border-radius: 4px; overflow-x: auto; white-space: pre-wrap; line-height: 1.4; border: 1px solid #e5e7eb; }

/* Typing indicator & input */
#typing-indicator { box-sizing: border-box; display: none; color: #6c757d; font-style: italic; padding: 12px 18px; margin-bottom: 10px; border-radius: 18px; background-color: #f1f3f5; align-self: flex-start; max-width: fit-content; margin-left: 32px; }
#input-form { display: flex; align-items: center; padding: 18px 32px; box-sizing: border-box; background-color: #f8f9fa; border-top: 1px solid #dee2e6; flex-shrink: 0; }
#user-input { flex: 1; padding: 14px 18px; font-size: 1.08rem; border: 1px solid #ced4da; border-radius: 12px; margin-right: 12px; outline: none; transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; min-height: 80px; max-height: 150px; resize: vertical; font-family: inherit; line-height: 1.5; }
#user-input:focus { border-color: #4dabf7; box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.25); }
#send-btn { padding: 14px 24px; font-size: 1.08rem; font-weight: 500; background-color: #28a745; color: #fff; border: none; border-radius: 20px; cursor: pointer; transition: background-color 0.2s ease-in-out; }
#send-btn:hover { background-color: #218838; }
#send-btn:disabled { background-color: #adb5bd; cursor: not-allowed; }

/* Save button */
#save-conversation-btn { position: fixed; top: 20px; right: 20px; background-color: #007bff; color: white; border: 1px solid #007bff; border-radius: 8px; padding: 8px 16px; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s ease-in-out; box-shadow: 0 2px 8px rgba(0,123,255,0.2); z-index: 1000; }
#save-conversation-btn:hover { background-color: #0056b3; border-color: #0056b3; box-shadow: 0 4px 12px rgba(0,123,255,0.3); }
#save-conversation-btn:disabled { background-color: #6c757d; border-color: #6c757d; cursor: not-allowed; box-shadow: 0 2px 8px rgba(108,117,125,0.2); } 

/* Quick response buttons */
.quick-responses { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; justify-content: center; flex-shrink: 0; }
.quick-response-btn { padding: 10px 20px; font-size: 1rem; background-color: #e9ecef; color: #495057; border: 1px solid #ced4da; border-radius: 16px; cursor: pointer; transition: all 0.2s ease-in-out; white-space: nowrap; }
.quick-response-btn:hover { background-color: #dee2e6; border-color: #adb5bd; }
.quick-response-btn:active { transform: translateY(1px); } 