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

/* Password overlay styles */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.password-box {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.password-box h2 {
  color: #333;
  margin-bottom: 10px;
  font-size: 24px;
}

.password-box p {
  color: #666;
  margin-bottom: 20px;
  font-size: 14px;
}

.password-box input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 15px;
  transition: border-color 0.3s;
}

.password-box input:focus {
  outline: none;
  border-color: #667eea;
}

.password-box button {
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.password-box button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.password-box button:active {
  transform: translateY(0);
}

.password-error {
  color: #e74c3c;
  font-size: 14px;
  margin-top: 10px;
  min-height: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 900px;
  width: 100%;
  padding: 40px;
  position: relative;
}

/* Version labels in upper right */
.version-labels {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  z-index: 10;
}

.version-item {
  font-size: 11px;
  color: #999;
  background: #f5f5f5;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

h1 {
  color: #333;
  margin-bottom: 10px;
  font-size: 28px;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-weight: 600;
  font-size: 14px;
}

textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.3s;
}

textarea:focus {
  outline: none;
  border-color: #667eea;
}

#question {
  min-height: 100px;
}

#answer {
  min-height: 300px;
  background-color: #f8f9fa;
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow-y: auto;
  line-height: 1.6;
}

/* Placeholder styling */
.answer-content .placeholder {
  color: #999;
  font-style: italic;
}

/* Markdown rendering styles */
.answer-content h1,
.answer-content h2,
.answer-content h3 {
  color: #333;
  margin-top: 20px;
  margin-bottom: 10px;
}

.answer-content h1 {
  font-size: 24px;
  border-bottom: 2px solid #667eea;
  padding-bottom: 8px;
}

.answer-content h2 {
  font-size: 20px;
  color: #667eea;
}

.answer-content h3 {
  font-size: 16px;
  color: #764ba2;
}

.answer-content p {
  margin-bottom: 12px;
  color: #333;
}

.answer-content ul,
.answer-content ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.answer-content li {
  margin-bottom: 6px;
  color: #333;
}

.answer-content strong {
  color: #667eea;
  font-weight: 600;
}

.answer-content em {
  color: #764ba2;
}

.answer-content code {
  background: #e8ecff;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #667eea;
}

.answer-content pre {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.answer-content pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.answer-content blockquote {
  border-left: 4px solid #667eea;
  padding-left: 16px;
  margin-left: 0;
  margin-bottom: 12px;
  color: #666;
  font-style: italic;
}

.answer-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 12px;
}

.answer-content th,
.answer-content td {
  border: 1px solid #e0e0e0;
  padding: 8px;
  text-align: left;
}

.answer-content th {
  background: #667eea;
  color: white;
  font-weight: 600;
}

.answer-content tr:nth-child(even) {
  background: #f8f9fa;
}

.language-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.language-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid #e0e0e0;
  background: white;
  color: #333;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

.language-btn:hover {
  border-color: #667eea;
}

.language-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.category-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.category-radio {
  display: none;
}

.category-label {
  padding: 8px 16px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s;
}

.category-label:hover {
  border-color: #667eea;
}

.category-radio:checked + .category-label {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 20px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.loading {
  display: none;
  text-align: center;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 10px;
}

.loading.active {
  display: block;
}

.error {
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: none;
}

.error.active {
  display: block;
}

.measurements {
  margin-top: 20px;
  padding: 16px;
  background: #fff4e6;
  border-radius: 8px;
  border-left: 4px solid #ff9800;
  display: none;
}

.measurements.active {
  display: block;
}

.measurements h3 {
  font-size: 14px;
  color: #ff9800;
  margin-bottom: 12px;
  font-weight: 600;
}

.measurements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.measurement-item {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  padding: 10px 14px;
  background: white;
  border-radius: 6px;
  border: 1px solid #ffe0b2;
  font-family: 'Courier New', monospace;
  text-align: center;
}

.citations {
  margin-top: 20px;
  padding: 20px;
  background: #f0f4ff;
  border-radius: 8px;
  display: none;
}

.citations.active {
  display: block;
}

.citations h3 {
  font-size: 18px;
  color: #667eea;
  margin-bottom: 16px;
  font-weight: 600;
}

.citation {
  font-size: 15px;
  line-height: 1.6;
  color: #444;
  margin-bottom: 16px;
  padding: 16px;
  background: white;
  border-radius: 6px;
  border-left: 3px solid #667eea;
}

.citation-header {
  font-size: 18px;
  color: #667eea;
  margin-bottom: 8px;
  font-weight: 700;
}

.citation-source {
  font-size: 13px;
  color: #888;
  margin-bottom: 10px;
  font-style: italic;
}

.citation-text {
  font-size: 14px;
  color: #555;
  line-height: 1.5;
}

.citation strong {
  color: #333;
  font-size: 16px;
}

.images-section {
  background: #fffef0;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  min-height: 100px;
}

.images-section h3 {
  font-size: 16px;
  color: #667eea;
  margin-bottom: 16px;
  font-weight: 600;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.image-item {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  background: white;
}

.image-item:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.image-caption {
  padding: 8px;
  font-size: 11px;
  color: #666;
  text-align: center;
  background: #f8f9fa;
}

.image-caption strong {
  display: block;
  margin-bottom: 4px;
  color: #333;
  font-size: 12px;
}

.image-context {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: #555;
  text-align: justify;
  font-style: italic;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  max-height: 90%;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

.modal-content {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  padding: 10px;
}

.modal-text {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px;
  font-size: 13px;
  color: #666;
  text-align: center;
  background: #f8f9fa;
  display: none;
}

.modal-text strong {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-size: 17px;
}

.modal-text p {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.5;
  color: #555;
  text-align: justify;
  font-style: italic;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: white;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
}

@media (max-width: 600px) {
  .container {
    padding: 20px;
  }

  h1 {
    font-size: 24px;
  }
}
