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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  min-height: 100vh;
  padding: 24px 16px;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

header {
  text-align: center;
  padding: 8px 0;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a1a2e;
}

.subtitle {
  color: #666;
  margin-top: 6px;
  font-size: 0.95rem;
}

/* Card style for sections */
.api-key-section,
.input-section,
.result-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

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

.api-key-row {
  display: flex;
  gap: 8px;
}

input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: #fafafa;
  color: #1a1a2e;
}

input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #6c63ff;
  background: #fff;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.hint {
  font-size: 0.8rem;
  color: #999;
  margin-top: 6px;
}

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

.form-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-count {
  font-weight: 400;
  font-size: 0.82rem;
  color: #888;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #6c63ff;
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

.btn-primary:hover:not(:disabled) {
  background: #5a52d5;
}

.btn-primary:disabled {
  background: #c4c0f7;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f0eefd;
  color: #6c63ff;
  flex-shrink: 0;
}

.btn-secondary:hover {
  background: #e0dcfa;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

/* Result section */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.result-header h2 {
  font-size: 1.1rem;
}

.result-content {
  font-size: 0.95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: #333;
}

/* Markdown-like rendering */
.result-content h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 16px 0 8px;
  color: #1a1a2e;
  border-bottom: 2px solid #f0eefd;
  padding-bottom: 4px;
}

.result-content h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 12px 0 6px;
  color: #444;
}

.result-content p {
  margin: 6px 0;
}

.result-content ul,
.result-content ol {
  margin: 6px 0 6px 20px;
}

.result-content li {
  margin: 4px 0;
}

.result-content strong {
  color: #1a1a2e;
}

.result-content code {
  background: #f5f7fa;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.result-content blockquote {
  border-left: 3px solid #6c63ff;
  padding: 8px 14px;
  margin: 10px 0;
  background: #f9f8ff;
  border-radius: 0 6px 6px 0;
  color: #555;
}

/* Streaming cursor */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #6c63ff;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}
