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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --border: #333;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #7c6fe0;
  --accent-hover: #6b5dd3;
  --error: #e05555;
  --success: #55b87a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.logo {
  color: var(--accent);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
}

/* Login */
.login-box {
  max-width: 320px;
  margin: 4rem auto;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 1rem;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Forms */
input[type="text"],
input[type="password"],
input[type="email"],
select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

button,
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background 0.15s;
}

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

.btn-secondary {
  background: var(--surface2);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
}

/* Search */
.search-form {
  margin-bottom: 1.5rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
}

.search-bar input {
  flex: 1;
}

.filters {
  margin-top: 0.75rem;
}

.filters summary {
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .filter-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.result-cover {
  flex-shrink: 0;
}

.result-cover img {
  width: 5rem;
  height: 7.5rem;
  object-fit: cover;
  border-radius: 4px;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.result-author {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.result-meta {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.result-desc {
  color: var(--text-dim);
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-actions {
  flex-shrink: 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.page-num {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Download */
.download-box {
  max-width: 480px;
  margin: 2rem auto;
}

.download-box h2 {
  margin-bottom: 0.5rem;
}

.md5-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  word-break: break-all;
}

.md5-label code {
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
}

.kindle-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.kindle-form h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.kindle-form input {
  width: 100%;
  margin-bottom: 0.5rem;
}

.fallback-link {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.fallback-link a {
  color: var(--accent);
}

.back-link {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Messages */
.error {
  color: var(--error);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.success {
  color: var(--success);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 0;
}

@media (max-width: 600px) {
  .result-card {
    flex-direction: column;
  }

  .result-actions {
    align-self: flex-start;
  }

  .filter-row {
    flex-direction: column;
  }
}
