:root {
  --bg: #152238;
  --surface: #1c2c48;
  --border: #35476a;
  --text: #f2f3f5;
  --text-muted: #a7b3c9;
  --accent: #4a8dff;
  --accent-hover: #6fa3ff;
  --error-bg: #3a1b1a;
  --error-text: #ff8a80;
  --error-border: #5c2b28;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
}

.logo {
  display: block;
  height: 96px;
  width: auto;
  margin: 0 auto 1rem;
}

.brand-title {
  margin: 0;
  font-size: 1.75rem;
}

.brand-subtitle {
  margin: 0.25rem 0 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.subtitle {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  max-width: 40rem;
  margin-inline: auto;
}

main {
  flex: 1;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.prompt-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 1rem;
  padding: 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  align-self: flex-end;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.status-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.error-section {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.error-section p {
  margin: 0;
  white-space: pre-wrap;
}

.result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-section h2 {
  margin: 0;
  font-size: 1.15rem;
}

.file-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.file-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: calc(var(--radius) - 4px);
}

.file-link:hover {
  background: var(--accent);
  color: white;
}

.viewer-container {
  width: 100%;
  height: 400px;
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.code-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.code-details pre {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  overflow-x: auto;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
