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

:root {
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #1a1a1a;
  --text-secondary: #666;
  --accent: #4a6cf7;
  --border: #e5e5e5;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--card-bg);
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  width: 320px;
}
.login-box h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.login-box input {
  width: 100%; padding: 0.6rem 0.8rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.95rem; margin-bottom: 1rem;
}
.login-box button {
  width: 100%; padding: 0.6rem;
  background: var(--accent); color: #fff; border: none;
  border-radius: 6px; font-size: 0.95rem; cursor: pointer;
}
.login-box button:hover { opacity: 0.9; }
.error { color: #e53935; font-size: 0.85rem; margin-top: 0.5rem; }

/* Hidden override */
[hidden] { display: none !important; }

/* Header */
.header {
  max-width: 1200px; margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
}
.header h1 { font-size: 1.3rem; margin-bottom: 0.8rem; }
.filters { display: flex; flex-direction: column; gap: 0.6rem; }
.filter-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.chip {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.chip.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.filter-row {
  display: flex; gap: 0.5rem;
}
.filter-row select, .filter-row input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.85rem; background: var(--card-bg);
}
.search-wrapper { position: relative; flex: 1; display: flex; }
.search-wrapper input[type="search"] { flex: 1; width: 100%; }
.search-btn {
  padding: 0.4rem 0.8rem;
  background: var(--accent); color: #fff; border: none;
  border-radius: 0 6px 6px 0; font-size: 0.85rem; cursor: pointer;
  white-space: nowrap;
}
.search-btn:hover { opacity: 0.9; }
.ai-param {
  width: 52px; padding: 0.4rem 0.3rem; text-align: center;
  border: 1px solid var(--border); border-left: none;
  font-size: 0.8rem; background: var(--card-bg);
}
.ai-param:first-of-type { border-radius: 0; }
.ai-search-btn { background: #7c3aed; }
.ai-search-btn:hover { opacity: 0.9; }
.search-wrapper input[type="search"] { border-radius: 6px 0 0 6px; }
.badge-score { background: #ede9fe; color: #7c3aed; }
.filter-row input[type="date"] { width: 130px; }
.date-sep {
  color: var(--text-secondary); font-size: 0.85rem;
  align-self: center;
}

/* Masonry */
.masonry {
  max-width: 1200px; margin: 1rem auto 0;
  padding: 0 1rem;
  columns: 3;
  column-gap: 1rem;
}

.card {
  break-inside: avoid;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.card-photo {
  width: 100%; display: block;
}
.card-body { padding: 0.8rem 1rem; }
.card-title {
  font-size: 0.95rem; font-weight: 600;
  margin-bottom: 0.3rem;
}
.card-meta {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.5rem; flex-wrap: wrap;
}
.badge {
  font-size: 0.7rem; padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge-category { background: #e8eaff; color: #4a6cf7; }
.badge-stars { background: #fff8e1; color: #f9a825; }
.badge-channel { background: #e8f5e9; color: #388e3c; font-size: 0.7rem; }
.card-date { font-size: 0.7rem; color: var(--text-secondary); }
.card-summary {
  font-size: 0.85rem; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 4;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* Load more */
.load-more-wrapper { text-align: center; padding: 1.5rem 0 2rem; }
.load-more-btn {
  padding: 0.5rem 2rem;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.load-more-btn:hover { background: #eee; }
.no-more, .loading {
  text-align: center; color: var(--text-secondary);
  padding: 1rem; font-size: 0.85rem;
}

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
}
.modal-content {
  position: relative; z-index: 1;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  max-width: 680px; width: 90%; max-height: 85vh;
  overflow-y: auto; padding: 1.5rem;
}
.modal-close {
  position: absolute; top: 0.5rem; right: 0.8rem;
  background: none; border: none;
  font-size: 1.5rem; cursor: pointer; color: var(--text-secondary);
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.modal-meta { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.modal-section { margin-bottom: 0.8rem; }
.modal-section-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; margin-bottom: 0.3rem;
}
.modal-section-text {
  font-size: 0.9rem; white-space: pre-wrap;
}
.modal-photo { max-width: 100%; border-radius: 6px; margin-bottom: 0.8rem; }
.modal-link {
  display: inline-block; margin-top: 0.5rem;
  color: var(--accent); font-size: 0.85rem; text-decoration: none;
}
.modal-link:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 900px) {
  .masonry { columns: 2; }
}
@media (max-width: 560px) {
  .masonry { columns: 1; }
  .header { padding: 1rem 0.8rem 0.3rem; }
}
