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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen { height: 100vh; }

/* Login */
.login-container {
  max-width: 400px;
  margin: 15vh auto;
  padding: 2rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  text-align: center;
}

.login-container h1 {
  font-size: 1.8rem;
  color: #1a1a2e;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: #666;
  margin-bottom: 1.5rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-form input {
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: #4361ee;
}

#login-form button {
  padding: 0.75rem;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

#login-form button:hover { background: #3a56d4; }
#login-form button:disabled { background: #a0a0a0; cursor: not-allowed; }

.error {
  color: #e63946;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Chat */
#chat-screen {
  display: flex;
  flex-direction: column;
}

#chat-screen[hidden] { display: none; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #1a1a2e;
  color: #fff;
}

header h1 { font-size: 1.2rem; }

.header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#model-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
}

#model-select option {
  background: #1a1a2e;
  color: #fff;
}

.compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: #fff;
  cursor: pointer;
  user-select: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
}

.compare-toggle input {
  cursor: pointer;
  accent-color: #4361ee;
}

#model-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}

#logout-btn:hover { background: rgba(255,255,255,0.1); }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #4361ee;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
  color: #1a1a2e;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}

.message.assistant .model-label {
  display: block;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #eee;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4361ee;
}

.message.assistant .model-label .ft-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  background: #fdecef;
  color: #c2185b;
  border: 1px solid #f4c7d2;
  border-radius: 4px;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
}

.message.assistant .stats {
  display: block;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid #eee;
  font-size: 0.75rem;
  color: #888;
  font-variant-numeric: tabular-nums;
}

.card-thinking {
  color: #999;
  font-style: italic;
  font-size: 0.875rem;
}

.card-error {
  color: #e63946;
  font-size: 0.875rem;
  background: #fff0f0;
  border: 1px solid #fcc;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  margin-top: 0.3rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
}

.compare-grid .compare-card {
  max-width: none;
  align-self: stretch;
}

@media (min-width: 900px) {
  .compare-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1400px) {
  .compare-grid { grid-template-columns: repeat(3, 1fr); }
}

.message.error-msg {
  align-self: center;
  background: #fff0f0;
  color: #e63946;
  border: 1px solid #fcc;
  font-size: 0.875rem;
}

.typing {
  align-self: flex-start;
  color: #888;
  font-style: italic;
  padding: 0.5rem 1rem;
}

.doc-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 1.5rem;
  padding: 0.4rem 0.75rem;
  background: #eef1fe;
  border: 1px solid #c7d0f4;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #1a1a2e;
  align-self: flex-start;
  max-width: calc(100% - 3rem);
}

.doc-chip[hidden] { display: none; }

.doc-chip .doc-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.doc-chip .doc-remove {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #4361ee;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}

.doc-chip .doc-remove:hover { color: #e63946; }

#chat-form {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: #fff;
  border-top: 1px solid #e0e0e0;
}

#attach-btn {
  flex-shrink: 0;
  width: 44px;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

#attach-btn:hover { border-color: #4361ee; background: #f5f7ff; }
#attach-btn.has-doc { border-color: #4361ee; background: #eef1fe; }

#prompt {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 150px;
}

#prompt:focus { border-color: #4361ee; }

#send-btn {
  padding: 0.75rem 1.5rem;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#send-btn:hover { background: #3a56d4; }
#send-btn:disabled { background: #a0a0a0; cursor: not-allowed; }
