:root {
  --bg: #0d0c0b;
  --surface: #161412;
  --border: #2a2622;
  --text: #e8e4e0;
  --muted: #8c857d;
  --accent: #c9a227;
  --accent-hover: #ddb83a;
  --error: #c75c5c;
  --radius: 12px;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  z-index: 0;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1.5rem;
}

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

.title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 400;
  margin: 0 0 0.35em;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
}

.input-section {
  margin-bottom: 2rem;
}

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

.input {
  flex: 1;
  min-width: 200px;
  padding: 0.85rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
  color: var(--muted);
}

.input:hover {
  border-color: #3d3832;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.btn-go {
  padding: 0.85rem 1.4rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
}

.btn-go:hover {
  background: var(--accent-hover);
}

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

.hint {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.result {
  margin-top: 2rem;
}

.result.hidden {
  display: none;
}

.cover-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.cover-frame {
  width: 220px;
  height: 220px;
  margin: 0 auto 1.25rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

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

.meta {
  margin-bottom: 1.25rem;
}

.meta-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0 0 0.2em;
}

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

.single-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.single-hint.hidden {
  display: none;
}

.btn-download {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.btn-download:hover {
  background: var(--accent-hover);
}

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

.covers-grid-wrap {
  margin-top: 1rem;
}

.covers-grid-wrap.hidden {
  display: none;
}

.covers-count {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.btn-download-all {
  margin-bottom: 1.25rem;
}

.covers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.cover-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.cover-tile-frame {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.cover-tile-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-tile-title {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  margin: 0 0 0.15em;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-tile-author {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cover-tile .btn-download {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.error,
.loading {
  text-align: center;
  padding: 1.5rem;
}

.error.hidden,
.loading.hidden {
  display: none;
}

.error-text {
  margin: 0;
  color: var(--error);
  font-size: 0.95rem;
}

.loading p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.bottom-right-svg {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 96px;
  height: 96px;
  padding: 4px;
  background: #ffffff;
  border: 3px solid var(--border);
  border-radius: 24px;
  z-index: 100;
  opacity: 1;
  transition: transform 0.2s, border-color 0.2s;
  pointer-events: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.bottom-right-svg:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}

@media (max-width: 600px) {
  .bottom-right-svg {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 64px;
    height: 64px;
    padding: 4px;
    border-width: 2px;
    border-radius: 16px;
  }
}