* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #f5f6f7;
  color: #1f2329;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 6px;
  color: #fff;
}

.header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 110px 110px 90px;
  gap: 12px;
  background: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  align-items: end;
}

@media (max-width: 768px) {
  .controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.controls.show-status {
  grid-template-columns: 1fr 110px 110px 110px 90px;
}

#statusControl {
  display: none;
}

.controls.show-status #statusControl {
  display: flex;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.control label {
  font-weight: 600;
  color: #64748b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.control input[type="text"],
.control select {
  height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 26px;
  transition: all 0.2s ease;
  outline: none;
  width: 100%;
  display: block;
  background: #f8fafc;
}

.control input[type="text"]:focus,
.control select:focus {
  border-color: #1e293b;
  box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1);
}

.control-action {
  align-content: end;
}

.control-action label {
  height: 12px;
  /* Set fixed height to match other labels exactly */
}

.control-action label.hidden-label {
  display: block;
  visibility: hidden;
}

.control-action button {
  height: 28px;
  background: #1e293b;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
  width: 100%;
}

.control-action button:hover {
  background: #334155;
}

.label-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}

.query-error {
  flex: 1;
  font-size: 11px;
  color: #ef4444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.control {
  position: relative;
}

.results-status {
  padding: 0 4px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.results-status .result-count {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-status .result-count::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background: #1e293b;
  border-radius: 2px;
}

.grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #e2e8f0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.card {
  display: grid;
  grid-template-columns: 2.5fr 1.5fr 80px 100px;
  align-items: center;
  gap: 12px;
  background: #fff;
  padding: 8px 16px;
  transition: background 0.15s ease;
  text-align: left;
}

.card:hover {
  background: #f8fafc;
}

.col-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-title a {
  color: #111827;
  text-decoration: none;
}

.col-title a:hover {
  text-decoration: underline;
}

.col-author {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-rating {
  font-size: 13px;
  font-weight: 700;
}

.col-count {
  font-size: 12px;
  font-weight: 500;
}

/* Source-based rating colors */
.source-db.col-rating,
.source-db.col-count {
  color: #16a34a;
  /* Green for Douban */
}

.source-gr.col-rating,
.source-gr.col-count {
  color: #d97706;
  /* Orange/Gold for Goodreads */
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.badge-db {
  background: #dcfce7;
  color: #16a34a;
}

.badge-gr {
  background: #fef3c7;
  color: #b45309;
}

.badge-read {
  background: #dbeafe;
  color: #1e40af;
  margin-left: 6px;
}

@media (max-width: 640px) {
  .card {
    grid-template-columns: 1fr 40px 40px;
    gap: 4px;
    padding: 8px 10px;
  }

  .col-author {
    display: none;
  }
}

.pagination {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.pagination button {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #1f2329;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 14px;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease;
}

.pagination button:hover {
  border-color: #1e293b;
  color: #1e293b;
}

.empty {
  padding: 32px;
  background: #fff;
  border-radius: 12px;
  text-align: center;
  color: #6b7280;
}