@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  background: #1a1b26;
  color: #a9b1d6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #363b54;
}
.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c0caf5;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.session-status {
  font-size: 0.78rem;
  font-weight: 500;
  color: #565f89;
}
.session-status.ok { color: #9ece6a; }
.session-status.warn { color: #e0af68; }

.debug-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #e0af68;
  color: #1a1b26;
}
.debug-badge.hidden { display: none; }

.btn {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary {
  background: #7aa2f7;
  color: #1a1b26;
}
.btn-primary:hover { background: #89b4fa; }
.btn-ghost {
  background: transparent;
  color: #a9b1d6;
  border: 1px solid #363b54;
}
.btn-ghost:hover { background: #363b54; color: #c0caf5; }
.btn-refresh { font-size: 1.1em; padding: 2px 6px; min-width: unset; cursor: pointer; }
.btn-refresh.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.search-section { margin-bottom: 1rem; }
.search-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.search-form input[type="search"] {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1px solid #363b54;
  border-radius: 6px;
  background: #24283b;
  color: #c0caf5;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 400;
  transition: border-color 0.15s;
}
.search-form input[type="search"]:focus {
  outline: none;
  border-color: #7aa2f7;
}
.search-form input::placeholder { color: #565f89; }
.search-form select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #363b54;
  border-radius: 6px;
  background: #24283b;
  color: #c0caf5;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}
.search-form select:focus {
  outline: none;
  border-color: #7aa2f7;
}

.results-wrap { min-height: 200px; }
.loading, .empty {
  text-align: center;
  color: #565f89;
  padding: 2rem;
  font-size: 0.9rem;
}
.empty-pre {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8rem;
  max-height: 60vh;
  overflow: auto;
  margin: 0;
}
.hidden { display: none !important; }

/* 瀑布流：多列 + 卡片上图下文，图片铺满列宽 */
.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  column-count: 2;
  column-gap: 1rem;
}
@media (min-width: 640px) {
  .results-list { column-count: 3; }
}
@media (min-width: 900px) {
  .results-list { column-count: 4; }
}
@media (min-width: 1200px) {
  .results-list { column-count: 5; column-gap: 1.25rem; }
}
.result-item {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 1rem;
  background: #24283b;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #363b54;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.result-item:hover {
  border-color: #565f89;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.result-item-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.result-thumb {
  width: 100%;
  aspect-ratio: 2/3;
  min-height: 180px;
  background: #1a1b26;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
.result-thumb:has(img) { cursor: zoom-in; }
.result-thumb:has(.result-thumb-placeholder) { cursor: default; }
.result-thumb.broken { display: none; }
.result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  vertical-align: top;
}
.result-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 180px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #565f89;
  background: #1a1b26;
  letter-spacing: 0.02em;
}
.result-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
}
.result-title {
  font-weight: 600;
  color: #dde3ff;
  font-size: 0.875rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
}
.result-smallDescr {
  font-size: 0.775rem;
  font-weight: 400;
  color: #7aa2f7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.result-title-zh {
  font-size: 0.775rem;
  font-weight: 400;
  color: #73daca;
  line-height: 1.4;
}
.result-title-zh::before {
  content: "CN";
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(115, 218, 202, 0.12);
  color: rgba(115, 218, 202, 0.7);
  border: 1px solid rgba(115, 218, 202, 0.25);
  border-radius: 3px;
  padding: 0 3px;
  margin-right: 5px;
  vertical-align: middle;
  line-height: 1.7;
}
.result-badges {
  font-size: 0.72rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}
.result-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.result-badge--free {
  background: rgba(0, 200, 83, 0.15);
  color: #9ece6a;
  border: 1px solid rgba(0, 200, 83, 0.35);
}
.result-badge--off {
  background: rgba(249, 169, 83, 0.15);
  color: #e0af68;
  border: 1px solid rgba(249, 169, 83, 0.35);
}
.result-badge--paid {
  background: rgba(136, 112, 255, 0.15);
  color: #bb9af7;
  border: 1px solid rgba(136, 112, 255, 0.35);
}
.result-stats {
  font-size: 0.75rem;
  font-weight: 500;
  color: #b8c0e0;
}
.result-stats .result-stat-size {
  color: #7dcfff;
  font-weight: 600;
}
.result-meta {
  font-size: 0.7rem;
  font-weight: 400;
  color: #6b7499;
  letter-spacing: 0.01em;
}
.result-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.result-actions .btn { margin-right: 0; font-size: 0.72rem; padding: 0.2rem 0.45rem; }

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.pagination button {
  padding: 0.35rem 0.6rem;
  border: 1px solid #363b54;
  border-radius: 4px;
  background: #24283b;
  color: #a9b1d6;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.pagination button:hover { background: #363b54; color: #c0caf5; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .current { background: #7aa2f7; color: #1a1b26; border-color: #7aa2f7; font-weight: 600; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-content {
  background: #24283b;
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #363b54;
}
.modal-content h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #dde3ff;
}
.modal-content fieldset {
  border: none;
  margin: 0 0 1rem;
  padding: 0;
}
.modal-content legend {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #565f89;
  margin-bottom: 0.5rem;
}
.modal-content label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #a9b1d6;
}
.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #363b54;
  border-radius: 6px;
  background: #1a1b26;
  color: #c0caf5;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.modal-content input:focus,
.modal-content textarea:focus {
  outline: none;
  border-color: #7aa2f7;
}
.modal-content textarea {
  resize: vertical;
  min-height: 4rem;
}
.settings-hint {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: #6b7499;
  line-height: 1.5;
}
.settings-hint code {
  background: #363b54;
  color: #7dcfff;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.8rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-content--wide {
  max-width: 90vw;
  width: 720px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.modal-header h2 {
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  flex-shrink: 0;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}
.detail-json {
  margin: 0;
  padding: 1rem;
  background: #1a1b26;
  border-radius: 6px;
  overflow: auto;
  max-height: 70vh;
  font-size: 0.78rem;
  color: #a9b1d6;
  white-space: pre-wrap;
  word-break: break-all;
}

.detail-posters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}
.detail-poster {
  max-width: 380px;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1b26;
}
.detail-poster.broken { display: none; }
.detail-poster img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
}
.detail-main {
  overflow: visible;
  min-height: 0;
}
.detail-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #dde3ff;
  margin-bottom: 0.5rem;
  line-height: 1.45;
}
.detail-smallDescr {
  font-size: 0.875rem;
  font-weight: 400;
  color: #7aa2f7;
  margin-bottom: 0.75rem;
  line-height: 1.45;
}
.detail-descr {
  font-size: 0.875rem;
  color: #b8c0e0;
  line-height: 1.6;
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: auto;
}
.detail-descr p { margin: 0.5rem 0; }
.detail-descr br { display: block; content: ""; margin-top: 0.25em; }
.detail-descr .descr-img {
  display: block;
  max-width: 100%;
  min-width: 200px;
  width: auto;
  height: auto;
  margin: 0.75rem 0;
  border-radius: 6px;
  vertical-align: top;
}
.detail-descr .descr-img[src=""] { display: none; }
.detail-translate-hint {
  margin: 0.5rem 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: #73daca;
}
.detail-zh-label { font-weight: 600; }
.detail-zh {
  margin-top: 0.25rem;
  padding: 0.75rem;
  background: #1a1b26;
  border-left: 2px solid rgba(115, 218, 202, 0.4);
  border-radius: 0 6px 6px 0;
  color: #c0caf5;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 0.875rem;
}
.detail-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.detail-actions .btn { margin-right: 0.25rem; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: zoom-out;
}
.lightbox.hidden { display: none !important; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}
.lightbox-img {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}
