:root {
  --paper: #f7f3ea;
  --card: #fffdf8;
  --ink: #2a2520;
  --muted: #6e655a;
  --line: #e2d9c8;
  --accent: #7a2e1f;
  --accent-soft: #f1e3d6;
  --gold: #b08a3e;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Assistant", "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* כותרת עליונה */
.top { border-bottom: 3px double var(--gold); background: var(--card); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.brand { font-family: "Frank Ruhl Libre", "David", serif; font-size: 1.6rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand small { display: block; font-family: "Assistant", sans-serif; font-size: .8rem; font-weight: 400; color: var(--muted); }
.top nav a { text-decoration: none; font-size: .95rem; white-space: nowrap; }

/* חיפוש */
.hero { padding: 28px 0 8px; }
.hero h1 { font-family: "Frank Ruhl Libre", "David", serif; font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 4px; }
.hero p { margin: 0 0 16px; color: var(--muted); }
#search-form { display: flex; gap: 8px; }
#q {
  flex: 1; min-width: 0;
  font: inherit; font-size: 1.1rem;
  padding: 12px 14px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
#q:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius);
  border: 2px solid var(--accent); background: var(--accent); color: #fff;
  text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); }
.hint { font-size: .9rem; color: var(--muted); margin: 8px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }
.chip {
  padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); text-decoration: none; font-size: .95rem;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
#count { color: var(--muted); font-size: .9rem; margin: 6px 0 14px; }
#empty { padding: 30px 0; text-align: center; color: var(--muted); }

/* רשימת נושאים */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 40px; }
.card {
  display: flex; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.card[hidden] { display: none; }
.card:hover { border-color: var(--gold); box-shadow: 0 2px 10px rgba(80,60,30,.08); }
.card img { width: 64px; height: 88px; object-fit: cover; border-radius: 4px; background: var(--accent-soft); flex-shrink: 0; }
.card h2, .card h3 { font-family: "Frank Ruhl Libre", "David", serif; font-size: 1.15rem; margin: 0 0 2px; line-height: 1.3; }
.tag { display: inline-block; font-size: .78rem; background: var(--accent-soft); color: var(--accent); padding: 1px 8px; border-radius: 999px; }
.src { font-size: .88rem; color: var(--muted); margin-top: 4px; }

/* דף נושא */
.crumbs { font-size: .9rem; color: var(--muted); padding: 14px 0 0; }
.crumbs a { text-decoration: none; }
.topic { display: grid; grid-template-columns: 200px 1fr; gap: 24px; padding: 16px 0 24px; }
.topic img.thumb { width: 100%; border-radius: 6px; border: 1px solid var(--line); background: var(--accent-soft); }
.topic h1 { font-family: "Frank Ruhl Libre", "David", serif; font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 4px 0 6px; line-height: 1.2; }
.meta { color: var(--muted); font-size: .95rem; margin-bottom: 14px; }
.sources { background: var(--card); border: 1px solid var(--line); border-right: 4px solid var(--gold); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
.sources h2 { font-size: 1rem; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.sources ul { margin: 0; padding: 0 18px 0 0; }
.sources li { font-family: "Frank Ruhl Libre", "David", serif; font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.viewer { margin: 0 0 30px; }
.viewer h2, .related h2 { font-family: "Frank Ruhl Libre", "David", serif; font-size: 1.3rem; }
.viewer iframe { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.related .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

footer { border-top: 1px solid var(--line); padding: 18px 0 30px; color: var(--muted); font-size: .9rem; text-align: center; }

@media (max-width: 640px) {
  .topic { grid-template-columns: 1fr; }
  .topic img.thumb { max-width: 160px; }
  .viewer iframe { height: 70vh; }
  .grid { grid-template-columns: 1fr; }
}
