@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Public+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #f7f9fc;
  --bg-grad-1: #eef4ff;
  --bg-grad-2: #f7f9fc;
  --surface: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5a6478;
  --ink-faint: #8a93a6;
  --brand: #1a73e8;
  --brand-soft: #e8f0fe;
  --brand-ink: #1558c0;
  --line: #e6eaf1;
  --shadow-sm: 0 1px 2px rgba(26, 34, 51, 0.06), 0 1px 3px rgba(26, 34, 51, 0.04);
  --shadow-md: 0 4px 14px rgba(26, 34, 51, 0.08);
  --shadow-lg: 0 12px 40px rgba(26, 34, 51, 0.12);
  --radius: 16px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Public Sans', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-grad-1), var(--bg-grad-2) 60%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

::selection { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- 3-column layout with reserved ad rails ---------- */
.layout {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 170px;
  gap: 28px;
  max-width: 1320px;
  margin: 0 auto;
  align-items: start;
  padding: 0 20px;
}
.center { min-width: 0; }
/* Reserved for future Google AdSense units — kept as clean empty whitespace. */
.ad-rail { min-height: 1px; }
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0; }
  .ad-rail { display: none; }
}

.wrap { max-width: 100%; margin: 0 auto; padding: 0 20px 96px; }

/* ---------- Hero / search ---------- */
.hero {
  padding: 72px 20px 28px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--bg-grad-1) 0%, rgba(247,249,252,0.96) 78%, rgba(247,249,252,0));
  backdrop-filter: blur(6px);
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand-ink); background: var(--brand-soft);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 18px;
}

h1.title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
}
h1.title em { font-style: italic; color: var(--brand); }

.subtitle { color: var(--ink-soft); font-size: 1rem; margin-top: 12px; }

.search-box {
  margin: 26px auto 8px;
  max-width: 640px;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow-md);
  transition: box-shadow .25s ease, border-color .25s ease, transform .25s ease;
}
.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft), var(--shadow-lg);
}
.search-box svg { flex: 0 0 auto; color: var(--ink-faint); }
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 1.05rem; font-family: inherit; color: var(--ink);
  padding: 12px 0;
}
.search-box input::placeholder { color: var(--ink-faint); }
.clear-btn {
  border: 0; background: transparent; color: var(--ink-faint);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; flex: 0 0 auto;
  transition: transform .2s ease, color .2s ease, opacity .2s ease;
}
.clear-btn:hover { transform: scale(1.06); color: var(--ink); }
.search-btn {
  border: 0; background: var(--brand); color: #fff;
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  padding: 0 22px; height: 44px; border-radius: 999px; cursor: pointer; flex: 0 0 auto;
  transition: transform .2s ease, background .2s ease;
}
.search-btn:hover { transform: translateY(-1px); background: var(--brand-ink); }
.search-btn:active { transform: translateY(0); }

/* search chips */
.pop-wrap { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pop-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-family: inherit; font-size: 0.85rem; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  transition: all .2s ease;
}
.chip:hover { color: var(--brand-ink); border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }

/* ---------- Results ---------- */
.meta-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 18px; color: var(--ink-faint); font-size: 0.85rem; font-weight: 500;
}
.intent-tag { color: var(--brand-ink); background: var(--brand-soft); padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; }
.meta-right { display: inline-flex; align-items: center; gap: 8px; }
.src-tag { color: #8a5a00; background: #fff4e0; border: 1px solid #ffe2b0; padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }

.results { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
  animation: rise .4s ease both;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #d6deeb; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Skeleton loaders ---------- */
.card.skeleton { animation: none; pointer-events: none; }
.sk { background: linear-gradient(90deg, #eef1f6 25%, #e3e8f1 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-cover { flex: 0 0 92px; height: 132px; border-radius: 10px; }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-title { height: 22px; width: 55%; margin-bottom: 12px; }
.sk-tags { display: flex; gap: 8px; margin: 12px 0; }
.sk-tag { width: 58px; height: 20px; border-radius: 999px; }
.sk-actions { display: flex; gap: 10px; margin-top: 16px; }
.sk-btn { width: 92px; height: 34px; border-radius: 999px; }

.cover {
  flex: 0 0 92px; height: 132px; border-radius: 10px;
  position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 10px; color: #fff;
}
.cover::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(0,0,0,0.28)); }
.cover .c-spine { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: rgba(0,0,0,0.22); }
.cover .c-title { position: relative; font-family: 'Fraunces', serif; font-weight: 600; font-size: 0.82rem; line-height: 1.15; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.cover .c-author { position: relative; font-size: 0.62rem; opacity: 0.9; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.cover.has-img { padding: 0; }
.cover.has-img::before { display: none; }
.cover .cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.year .rate { color: #e8710a; font-weight: 700; }

.card-body { flex: 1; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.book-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.28rem; letter-spacing: -0.01em; color: var(--ink); }
.book-author { color: var(--ink-soft); font-size: 0.92rem; }
.book-author b { color: var(--ink); font-weight: 600; }
.year { color: var(--ink-faint); font-size: 0.82rem; font-weight: 600; white-space: nowrap; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tag { font-size: 0.72rem; font-weight: 600; color: var(--ink-soft); background: #f1f4f9; border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; text-transform: capitalize; }
.tag.mood { color: var(--brand-ink); background: var(--brand-soft); border-color: #d5e3fb; }

.summary { color: var(--ink-soft); font-size: 0.94rem; }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
  transition: all .2s ease;
}
.btn:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-ink); color: #fff; }
.btn svg { transition: transform .25s ease; }
.btn.open svg { transform: rotate(180deg); }

/* accordion */
.panel { overflow: hidden; max-height: 0; transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s ease, margin .3s ease; opacity: 0; }
.panel.open { max-height: 800px; opacity: 1; margin-top: 16px; }
.panel-inner { border-top: 1px dashed var(--line); padding-top: 16px; display: grid; gap: 16px; }
.panel h4 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); margin-bottom: 6px; font-weight: 700; }
.panel p { font-size: 0.92rem; color: var(--ink-soft); }
.panel ul { list-style: none; display: grid; gap: 6px; }
.panel li { font-size: 0.92rem; color: var(--ink-soft); padding-left: 22px; position: relative; }
.panel li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }

.similar { display: flex; flex-direction: column; gap: 8px; }
.sim-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: all .2s ease; }
.sim-item:hover { border-color: var(--brand); background: var(--brand-soft); transform: translateX(3px); }
.sim-dot { width: 34px; height: 46px; border-radius: 5px; flex: 0 0 auto; box-shadow: var(--shadow-sm); }
.sim-cover { display: block; width: 34px; height: 50px; border-radius: 5px; flex: 0 0 auto; object-fit: cover; box-shadow: var(--shadow-sm); background: #eef1f6; }
.sim-meta { min-width: 0; }
.sim-title { font-weight: 600; font-size: 0.9rem; color: var(--ink); }
.sim-sub { font-size: 0.78rem; color: var(--ink-faint); }
.sim-shared { margin-left: auto; font-size: 0.72rem; color: var(--brand-ink); background: var(--brand-soft); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

.empty { text-align: center; padding: 64px 20px; color: var(--ink-faint); }
.empty .big { font-family: 'Fraunces', serif; font-size: 1.4rem; color: var(--ink-soft); margin-bottom: 8px; }

.footer { text-align: center; color: var(--ink-faint); font-size: 0.8rem; padding: 32px 0 0; }

@media (max-width: 560px) {
  .hero { padding: 48px 16px 20px; }
  .cover { flex-basis: 74px; height: 106px; }
  .card { padding: 14px; gap: 14px; }
  .actions { flex-wrap: wrap; }
}
