* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f3f4f6;
  color: #111827;
  line-height: 1.5;
}

.page {
  max-width: 1200px;
  margin: 0 auto 64px;
  padding: 0 20px;
}

.header {
  margin: 0 -20px 28px;
  padding: 42px 32px 46px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(29, 78, 216, 0.98) 0%, rgba(37, 99, 235, 0.96) 48%, rgba(59, 130, 246, 0.92) 100%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.22), transparent 34%);
  box-shadow: 0 18px 38px rgba(29, 78, 216, 0.22);
}

.header h1 {
  max-width: 920px;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
}

.header p {
  max-width: 720px;
  color: #e0ecff;
  font-size: 16px;
}

.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.06);
}

.form-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  color: #1f2937;
}

textarea,
input[type="password"] {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  color: #111827;
  resize: vertical;
  width: 100%;
}

textarea:focus,
input[type="password"]:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
  outline: none;
}

.mode-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  font-weight: 600;
  color: #1f2937;
}

.radio {
  display: flex;
  gap: 6px;
  align-items: center;
  font-weight: 500;
}

.api-key small {
  font-weight: 400;
  color: #4b5563;
}

.api-key a {
  color: #1d4ed8;
  text-decoration: none;
}

.api-key a:hover {
  text-decoration: underline;
}

.actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 20px;
}

button {
  background: #22c55e;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.24);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

button:hover:not(:disabled) {
  background: #16a34a;
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.28);
  transform: translateY(-1px);
}

button:disabled {
  background: #86efac;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-button {
  background: #1d4ed8;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.18);
}

.secondary-button:hover:not(:disabled) {
  background: #2563eb;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.status {
  color: #374151;
  font-size: 14px;
}

.output h2 {
  margin-bottom: 10px;
  font-size: 18px;
  color: #111827;
}

.markdown-output {
  width: 100%;
  min-height: 240px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 14px 16px;
  background: #ffffff;
  color: #111827;
  overflow: auto;
  line-height: 1.7;
}

.markdown-output:empty::before {
  content: attr(data-placeholder);
  color: #6b7280;
}

.markdown-output h1,
.markdown-output h2,
.markdown-output h3,
.markdown-output h4 {
  margin: 0.6em 0 0.4em;
}

.markdown-output p {
  margin: 0.4em 0;
}

.markdown-output ul,
.markdown-output ol {
  margin: 0.4em 0 0.4em 1.2em;
}

.markdown-output code {
  background: #eff6ff;
  padding: 0 4px;
  border-radius: 4px;
}

.markdown-output pre {
  background: #111827;
  color: #f7f8ff;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
}

.markdown-output .katex {
  font-size: 1em;
  line-height: 1.2;
}

.markdown-output .katex-display {
  margin: 0.6em 0;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .page {
    padding: 0 14px;
  }

  .header {
    margin: 0 -14px 22px;
    padding: 32px 20px 36px;
  }

  .header h1 {
    font-size: 24px;
  }

  .card {
    padding: 18px;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .form-toolbar {
    justify-content: stretch;
  }

  button {
    width: 100%;
  }
}
