:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-alt: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 2.5rem 1rem;
  background: radial-gradient(circle at top, #16233c 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1.75rem;
  text-align: center;
}

.page-header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

fieldset {
  margin: 0;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

legend {
  padding: 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: flex;
  gap: 1rem;
}

.field-row .field {
  flex: 1;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea,
select,
input[type="file"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

input[type="file"] {
  padding: 0.5rem;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

::placeholder {
  color: #64748b;
}

.preview {
  margin: 0;
  text-align: center;
}

.preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.preview figcaption {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.actions {
  display: flex;
  gap: 0.75rem;
}

button {
  padding: 0.7rem 1.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #04263a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

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

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

button.secondary:hover {
  border-color: var(--accent);
  color: var(--text);
}

.output {
  margin-top: 1.75rem;
}

.output h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.output pre {
  margin: 0.5rem 0 0;
  padding: 1rem;
  max-height: 320px;
  overflow: auto;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #7dd3fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 480px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .actions {
    flex-direction: column;
  }
}

/* --- Search page ---------------------------------------------------------- */

.container.wide {
  max-width: 1100px;
}

.site-nav {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.site-nav a {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.site-nav a:hover {
  border-color: var(--accent);
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #04263a;
}

.search-field {
  margin-bottom: 1rem;
}

.search-field:last-child {
  margin-bottom: 0;
}

.search-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 0.4rem 0 0.5rem;
  font-size: 0.8rem;
}

.mode label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 500;
  color: var(--muted);
}

.mode-inputs {
  display: flex;
  gap: 0.5rem;
}

.mode-inputs input {
  flex: 1;
}

.status {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.result-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.result-image-link {
  display: block;
  background: #0b1220;
}

.result-card img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.result-title {
  margin: 0.75rem 0.75rem 0;
  font-size: 1rem;
}

.result-description {
  margin: 0.35rem 0.75rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.result-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.6rem;
  margin: 0.6rem 0.75rem 0.75rem;
  font-size: 0.78rem;
}

.result-meta dt {
  color: var(--muted);
  font-weight: 600;
}

.result-meta dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.pager {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
