:root {
  --bg-primary: #18181b;
  --bg-surface: #222228;
  --bg-surface-alt: #2c2c33;

  --border: #3f3f46;

  --text-primary: #f4f4f5;
  --text-muted: #a1a1aa;

  --accent: #8b5cf6;
  --accent-light: #a78bfa;

  --error: #f87171;
  --error-border: #b91c1c;
  --error-bg: #1f1012;

  --radius: 0.75rem;
}

body {
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(40rem circle at 50% 100%, #3b1a6e 0%, transparent 70%),
    var(--bg-primary);
  padding: 2rem;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  z-index: -1;
  animation: slide-up 0.6s ease-out 0.3s forwards;
  pointer-events: none;
}

@keyframes slide-up {
  to {
    transform: translateY(-100%);
  }
}

code,
pre {
  font-family: "Geist Mono", ui-monospace, monospace;
}

.container {
  max-width: 36rem;
  width: 100%;
}

.logo {
  margin: 0 0 2rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-light);
}

.heading {
  margin: 0;
  font-size: 3rem;
  font-weight: 600;
  line-height: 1.25;
}

.emphasis {
  position: relative;
}

.emphasis::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0.1em;
  height: 4px;
  width: 100%;
  background: linear-gradient(to right, var(--accent) 10%, rgb(from var(--accent) r g b / 0.3));
  z-index: -1;
  transform: scaleX(0) skewX(-12deg);
  transform-origin: left;
  border-radius: 2px;
  animation: grow-underline 0.6s ease-out 0.3s forwards;
}

@keyframes grow-underline {
  to {
    transform: scaleX(1) skewX(-12deg);
  }
}

.subheading {
  color: var(--text-muted);
  line-height: 1.6;
}

.card {
  margin-top: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  padding: 1rem;
}

.card + .card {
  margin-top: 1rem;
}

.card-label {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

form {
  display: flex;
  flex-direction: column;
}

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  padding: 3rem;
  transition:
    border-color 0.2s,
    background-color 0.2s;
}

.upload-area:hover {
  border-color: var(--accent-light);
  background-color: rgb(from var(--accent) r g b / 0.1);
}

.upload-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  width: 2.5rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  background-color: var(--bg-surface-alt);
}

.upload-icon {
  height: 1.5rem;
  width: 1.5rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

.upload-text {
  color: var(--text-muted);
}

.upload-link {
  color: var(--accent-light);
  font-weight: 500;
}

.formats-trigger {
  position: relative;
  color: var(--accent-light);
  font-weight: 500;
  cursor: default;
  text-decoration: underline;
  white-space: nowrap;
}

.formats-popover {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 0.5rem);
  z-index: 10;
  width: max-content;
  padding: 0.75rem;
  white-space: normal;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--bg-surface-alt);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
}

.formats-trigger:hover .formats-popover {
  display: block;
}

.formats-group {
  display: block;
}

.formats-group + .formats-group {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.formats-group-label {
  display: block;
  font-size: 0.675rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.formats-group-items {
  display: block;
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  border-radius: var(--radius);
  background-color: var(--bg-surface-alt);
  padding: 1rem;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.file-icon {
  height: 2rem;
  width: 2rem;
  flex-shrink: 0;
  color: var(--accent-light);
}

.file-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.remove-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}

.remove-btn:hover {
  color: var(--text-primary);
}

.remove-icon {
  height: 1.25rem;
  width: 1.25rem;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  margin-top: 1.2rem;
  width: 100%;
  height: 3rem;
  border-radius: var(--radius);
  border: none;
  background-color: var(--accent);
  font-weight: 500;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 200ms;
}

.generate-btn:hover:not(:disabled) {
  transform: scale(1.02);
}

.generate-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    to right,
    transparent,
    rgb(from var(--text-primary) r g b / 0.2),
    transparent
  );
  transition: transform 500ms;
}

.generate-btn:hover:not(:disabled)::before {
  transform: translateX(100%);
}

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

.btn-spinner {
  display: none;
  width: 1.5rem;
  height: 1.5rem;
  animation: spin 1s linear infinite;
}

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

.htmx-request .btn-label {
  display: none;
}

.htmx-request .btn-spinner {
  display: block;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 0;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border);
}

.settings-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.settings-number {
  width: 3.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.settings-number:focus {
  border-color: var(--accent);
}

.settings-number::-webkit-inner-spin-button,
.settings-number::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.settings-range-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.settings-range {
  -webkit-appearance: none;
  appearance: none;
  width: 10rem;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-light);
  cursor: pointer;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px rgb(from var(--accent) r g b / 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.settings-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgb(from var(--accent) r g b / 0.2);
}

.settings-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-light);
  cursor: pointer;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px rgb(from var(--accent) r g b / 0.3);
}

.settings-range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.settings-range-value {
  min-width: 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "Geist Mono", ui-monospace, monospace;
}

#results {
  margin-top: 1.5rem;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.keyword {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgb(from var(--accent) r g b / 0.4);
  background-color: rgb(from var(--accent) r g b / 0.1);
  color: color-mix(in srgb, var(--text-primary) 50%, var(--accent-light));
}

.error {
  margin-top: 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--error-border);
  background-color: var(--error-bg);
  padding: 1rem;
  color: var(--error);
}
