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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

/* Auth screen */
#auth-screen {
  position: fixed;
  inset: 0;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-icon { font-size: 2rem; }

.auth-card h2 { font-size: 1.4rem; color: #1a1a2e; }

.auth-card > p { font-size: 0.9rem; color: #666; }

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

#password-input {
  padding: 0.65rem 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}
#password-input:focus { border-color: #3949ab; }

#auth-form button {
  padding: 0.65rem;
  background: #3949ab;
  color: #fff;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
#auth-form button:hover { background: #283593; }

#auth-error {
  font-size: 0.85rem;
  color: #c62828;
  min-height: 1.1em;
}

.app {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

header { text-align: center; }
header h1 { font-size: 1.8rem; color: #1a1a2e; }
header .subtitle { color: #666; margin-top: 0.25rem; font-size: 0.9rem; }

/* Upload */
.upload-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.upload-label {
  cursor: pointer;
  padding: 0.45rem 1rem;
  background: #e8eaf6;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #3949ab;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}
.upload-label:hover { background: #c5cae9; }

#upload-status { font-size: 0.85rem; color: #555; flex: 1; }

/* Chat */
.chat-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 420px;
  max-height: 520px;
  overflow-y: auto;
}

.message {
  padding: 0.65rem 1rem;
  border-radius: 10px;
  line-height: 1.5;
  font-size: 0.92rem;
  max-width: 88%;
  white-space: pre-wrap;
}

.message.user {
  background: #3949ab;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.message.assistant {
  background: #f1f3f4;
  color: #222;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.message.system {
  background: #fff8e1;
  color: #795548;
  align-self: center;
  font-size: 0.85rem;
  font-style: italic;
}

.message.error {
  background: #ffebee;
  color: #c62828;
  align-self: center;
  font-size: 0.85rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid #eee;
}

#user-input {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s;
}
#user-input:focus { border-color: #3949ab; }
#user-input:disabled { background: #fafafa; }

button {
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

#upload-btn, #send-btn {
  background: #3949ab;
  color: #fff;
}
#upload-btn:not(:disabled):hover, #send-btn:not(:disabled):hover { background: #283593; }

#reset-btn {
  background: #eceff1;
  color: #555;
  font-size: 1.1rem;
  padding: 0.55rem 0.75rem;
}
#reset-btn:not(:disabled):hover { background: #cfd8dc; }
