:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --gray: #6b7280;
  --gray-light: #f3f4f6;
  --shadow: 0 10px 25px rgba(0,0,0,0.1);
}

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

.hidden {
  display: none !important;
}

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

.container {
  width: 100%;
  max-width: 1100px;
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

header p {
  opacity: 0.9;
  font-size: 1.1rem;
}

main {
  padding: 40px;
}

.step {
  display: none;
}

.step.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  color: var(--primary-dark);
  margin-bottom: 25px;
  font-size: 1.8rem;
}

/* Painting Display Section */
.painting-info {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.details {
  background: var(--gray-light);
  padding: 20px;
  border-radius: 10px;
}

.details h3 {
  color: var(--primary-dark);
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.details .artist {
  font-size: 1.1rem;
  color: var(--gray);
  margin-bottom: 15px;
}

.details .meta {
  font-size: 0.95rem;
  color: var(--gray);
  margin-bottom: 8px;
}

.museum-link {
  display: inline-block;
  margin-top: 15px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.museum-link:hover {
  color: var(--primary-dark);
}

.painting-display img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* Buttons */
.btn-primary, .btn-secondary {
  border: none;
  padding: 15px 30px;
  border-radius: 50px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary.small {
  padding: 10px 20px;
  font-size: 0.9rem;
  margin-top: 12px;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-light);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.evaluation-cta {
  text-align: center;
  margin-top: 24px;
}

/* Loader */
.loader {
  width: 50px;
  height: 50px;
  border: 4px solid var(--gray-light);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 30px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Generation Status */
.generation-status {
  text-align: center;
  margin: 30px 0;
}

.generation-status p {
  color: var(--primary-dark);
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.generation-status small {
  color: var(--gray);
}

.generation-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 30px;
}

.preview-box {
  background: var(--gray-light);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.preview-box h3 {
  margin-bottom: 15px;
  color: var(--primary-dark);
}

.preview-box img {
  width: 100%;
  border-radius: 10px;
  object-fit: contain;
  max-height: 360px;
  box-shadow: var(--shadow);
}

.generated-preview img {
  width: 100%;
  border-radius: 10px;
  box-shadow: var(--shadow);
  object-fit: contain;
  max-height: 360px;
}

.generated-placeholder {
  text-align: center;
  color: var(--gray);
  padding: 40px 20px;
  border: 2px dashed rgba(99, 102, 241, 0.2);
  border-radius: 10px;
}

.evaluation-prompt-editor {
  margin-top: 30px;
  background: var(--gray-light);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.evaluation-prompt-editor textarea {
  width: 100%;
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 12px;
  font-family: monospace;
  resize: vertical;
  min-height: 140px;
}

.evaluation-prompt-editor textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.evaluation-prompt-editor .editor-label {
  display: block;
  font-weight: 600;
  color: var(--primary-dark);
}

.evaluation-prompt-editor .editor-hint {
  display: block;
  margin-top: 8px;
  color: var(--gray);
  font-size: 0.85rem;
}

/* Result Box */
.result-box {
  background: var(--gray-light);
  padding: 20px;
  border-radius: 10px;
  margin-top: 20px;
  white-space: pre-wrap;
  font-family: monospace;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

.result-box.active {
  display: block;
}

/* Comparison */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.image-box {
  text-align: center;
}

.image-box h3 {
  color: var(--primary-dark);
  margin-bottom: 15px;
  font-size: 1.4rem;
}

.image-box img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
}

.artwork-credit {
  font-size: 0.9rem;
  color: var(--gray);
  margin-top: 10px;
}

/* Scores */
.scores {
  background: var(--gray-light);
  padding: 25px;
  border-radius: 10px;
  margin-bottom: 30px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #ddd;
}

.score-item:last-child {
  border-bottom: none;
}

.score-item.total {
  margin-top: 15px;
  padding-top: 20px;
  border-top: 2px solid var(--primary);
  font-weight: bold;
  font-size: 1.3rem;
}

.score-bar {
  display: flex;
  align-items: center;
  gap: 15px;
}

.score-progress {
  width: 150px;
  height: 10px;
  background: #ddd;
  border-radius: 5px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--success) 100%);
  transition: width 1s ease;
}

.total-score {
  display: flex;
  align-items: center;
  gap: 15px;
}

.grade {
  display: inline-block;
  padding: 8px 15px;
  border-radius: 50px;
  color: white;
  font-weight: bold;
  font-size: 1.2rem;
}

.points {
  color: var(--primary-dark);
  font-size: 1.2rem;
}

.comment-box {
  margin-top: 25px;
  padding: 20px;
  background: white;
  border-radius: 8px;
}

.comment-box h4 {
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.comment-box p {
  color: var(--gray);
  line-height: 1.6;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 30px;
}

/* Error Section */
.error-box {
  background: #fef2f2;
  border: 2px solid var(--danger);
  color: var(--danger);
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  text-align: center;
}

/* Footer */
footer {
  background: var(--gray-light);
  text-align: center;
  padding: 20px;
  color: var(--gray);
}

footer small {
  display: block;
  margin-top: 5px;
  opacity: 0.8;
}

/* Prompt Input Section */
.prompt-input-section {
  margin-top: 30px;
  padding: 25px;
  background: var(--gray-light);
  border-radius: 10px;
}

.prompt-input-section h3 {
  color: var(--primary-dark);
  margin-bottom: 15px;
}

#user-prompt {
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  resize: vertical;
  transition: border-color 0.3s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#user-prompt:focus {
  outline: none;
  border-color: var(--primary);
}

.prompt-tips {
  margin: 10px 0;
  padding: 10px 15px;
  background: #fff9e6;
  border-left: 4px solid var(--secondary);
  border-radius: 4px;
}

.prompt-tips p {
  margin: 0;
  color: #666;
  font-size: 0.95rem;
}

.prompt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.prompt-counter {
  font-size: 0.9rem;
  color: var(--gray);
}

.prompt-counter.over {
  color: var(--danger);
  font-weight: 600;
}

.prompt-counter span {
  font-weight: 600;
}

.api-key-input {
  margin-bottom: 15px;
  background: var(--gray-light);
  padding: 15px;
  border-radius: 8px;
}

.api-key-input label {
  display: block;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.api-key-input input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 1rem;
}

.api-key-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.api-key-hint {
  display: block;
  margin-top: 6px;
  color: var(--gray);
  font-size: 0.85rem;
}

.prompt-display {
  margin: 15px 0;
  padding: 15px;
  background: white;
  border-radius: 8px;
  font-style: italic;
  color: var(--gray);
}

.your-prompt-section {
  margin: 20px 0;
  padding: 15px;
  background: var(--gray-light);
  border-radius: 8px;
}

.your-prompt-section h4 {
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.your-prompt-section p {
  color: #333;
  font-style: italic;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
  .painting-info {
    grid-template-columns: 1fr;
  }

  .comparison {
    grid-template-columns: 1fr;
  }

  header h1 {
    font-size: 2rem;
  }

  main {
    padding: 20px;
  }

  .action-buttons {
    flex-direction: column;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
  }

  .generation-preview {
    grid-template-columns: 1fr;
  }

  .preview-box {
    padding: 15px;
  }

  .evaluation-prompt-editor {
    padding: 15px;
  }
}

.evaluation-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 30px 0;
  color: var(--gray);
}

.evaluation-wait .loader {
  width: 60px;
  height: 60px;
}

/* APIキー検証関連のスタイル */
.api-key-controls {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.api-key-controls input {
  flex: 1;
}

.validate-btn {
  padding: 8px 16px;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}

.validate-btn:hover:not(:disabled) {
  opacity: 0.8;
}

.validate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.api-key-success {
  color: var(--success);
}

.api-key-error {
  color: var(--danger);
}

.api-key-validating {
  color: var(--secondary);
  font-style: italic;
}
