:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-alt: #f4f2ed;
  --ink: #1c1d1f;
  --muted: #6b6f73;
  --accent: #7a4e2d;
  --accent-ink: #fff7e6;
  --border: #e5e0d6;
  --mark: #fff3b0;
  --link: #5d3b22;
  --link-hover: #8c5a3a;
  --radius: 6px;
  --font-sans: "Noto Sans Hebrew", "SBL Hebrew", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "SBL Hebrew", "Noto Serif Hebrew", Georgia, serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

html[lang="yi"] body, html[dir="rtl"] body {
  text-align: start;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { color: var(--link-hover); text-decoration: underline; }

header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}
header.site .inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
header.site h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
header.site nav {
  display: flex;
  gap: 14px;
  font-size: 0.92rem;
}
header.site .search {
  flex: 1;
  max-width: 420px;
}
header.site .search input[type="search"] {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font: inherit;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

footer.site {
  max-width: 1100px;
  margin: 40px auto 20px;
  padding: 20px;
  color: var(--muted);
  font-size: 0.86rem;
  border-top: 1px solid var(--border);
}

/* ---- Forum index ---- */
.forum-group { margin-bottom: 24px; }
.forum-group > h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}
ul.forum-list, ul.topic-list, ul.post-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
ul.forum-list li, ul.topic-list li {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
ul.forum-list li:first-child, ul.topic-list li:first-child { border-top: 0; }

.forum-row, .topic-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px; align-items: center;
}
.forum-row .title, .topic-row .title {
  font-weight: 600;
}
.topic-row .title a { color: var(--ink); }
.forum-row .desc, .topic-row .meta {
  color: var(--muted);
  font-size: 0.88rem;
  grid-column: 1 / -1;
}
.forum-row .count, .topic-row .count {
  color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.86rem;
  text-align: end;
  white-space: nowrap;
}
.forum-row .recent, .topic-row .recent {
  color: var(--muted); font-size: 0.82rem;
  text-align: end;
  direction: ltr;
  white-space: nowrap;
}

/* ---- Topic / posts ---- */
.topic-header {
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.topic-header h1 {
  margin: 0; font-size: 1.35rem; font-weight: 700;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.post-head {
  background: var(--surface-alt);
  padding: 10px 14px;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 0.88rem; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.post-head .author { font-weight: 600; color: var(--ink); }
.post-head .time { direction: ltr; }
.post-subject { font-weight: 600; padding: 10px 14px 0; color: var(--ink); }
.post-body { padding: 12px 16px; }
.post-body blockquote.post-quote {
  background: var(--surface-alt);
  border-inline-start: 3px solid var(--accent);
  margin: 10px 0;
  padding: 8px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-body blockquote.post-quote cite {
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
}
.post-body blockquote.post-quote .quote-body { margin-top: 6px; }
.post-body img { max-width: 100%; height: auto; }
.video-embed {
  position: relative;
  max-width: 640px;
  aspect-ratio: 16/9;
  margin: 10px 0;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.video-embed iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
.video-fallback {
  font-size: 0.85rem; color: var(--muted); direction: ltr;
  margin-bottom: 10px; word-break: break-all;
}
.attachment-missing {
  display: inline-block;
  padding: 6px 12px;
  margin: 4px 0;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.88rem;
}
.attachment-image {
  display: inline-block;
  margin: 4px 0;
  line-height: 0;
}
.attachment-image img {
  max-width: 100%;
  max-height: 640px;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.attachment-file {
  display: inline-block;
  padding: 6px 12px;
  margin: 4px 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.attachment-size { color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.attachment-media {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0;
  max-width: 100%;
}
.attachment-media video { max-width: 100%; max-height: 480px; }
.post-attachments {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px dashed var(--border);
}
.post-attachments .attachment-image img { max-height: 280px; }
.post-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 0.85rem; color: var(--muted);
}
.badge-raw {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-inline-start: 6px;
}
.post-foot-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
pre.raw-bbcode {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  overflow-x: auto;
}
.badge-edit, .badge-pending {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.badge-pending { background: #fef4e5; border-color: #e8c58d; color: #8a5600; }
.badge-restored {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #e8f0e6;
  border: 1px solid #b8ccb0;
  color: #3d5a33;
}
.thanks-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 0.88rem; }
.thanks-list .thanks-icon { margin-inline-end: 2px; }
.thanks-list .thanks-sep { color: var(--muted); }

.filter-toggle {
  display: inline-flex; gap: 2px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2px; background: var(--surface);
}
.filter-toggle a {
  padding: 6px 14px; border-radius: calc(var(--radius) - 2px);
  font-size: 0.9rem; color: var(--muted); text-decoration: none;
}
.filter-toggle a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---- Pagination ---- */
.pagination {
  display: flex; gap: 6px; align-items: center;
  justify-content: center;
  margin: 20px 0;
}
.pagination a, .pagination span {
  min-width: 32px; padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pagination span.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pagination .muted { border: 0; color: var(--muted); }

/* ---- Search ---- */
.search-page form.filters {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  background: var(--surface);
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px;
}
.search-page form.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.search-page form.filters input, .search-page form.filters select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; background: var(--bg);
}
.search-page form.filters button {
  grid-column: 1 / -1;
  padding: 8px 14px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius);
  font-weight: 600; cursor: pointer;
}
.search-result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.search-result .meta { color: var(--muted); font-size: 0.85rem; direction: ltr; }
.search-result mark { background: var(--mark); color: inherit; padding: 0 2px; }

/* ---- User profile ---- */
.user-profile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.user-profile h1 { margin: 0 0 4px; }
.user-profile .stat { color: var(--muted); }

/* ---- Edit history ---- */
.revision { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.revision-meta { color: var(--muted); font-size: 0.85rem; direction: ltr; margin-bottom: 6px; }
.revision-body { padding: 6px 0; }

/* ---- Login ---- */
.login-page { max-width: 360px; margin: 60px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.login-page h1 { margin-top: 0; }
.login-page input[type="password"] { width: 100%; padding: 8px; font: inherit; border: 1px solid var(--border); border-radius: var(--radius); }
.login-page button { width: 100%; margin-top: 10px; padding: 8px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius); font-weight: 600; cursor: pointer; }
.login-page .error { color: #b42a2a; margin: 8px 0; }

/* Breadcrumb */
nav.breadcrumb { font-size: 0.88rem; color: var(--muted); margin-bottom: 12px; direction: rtl; }
nav.breadcrumb a { color: var(--muted); }

/* small screens */
@media (max-width: 700px) {
  .forum-row, .topic-row { grid-template-columns: 1fr; }
  .forum-row .count, .topic-row .count, .forum-row .recent, .topic-row .recent { text-align: start; }
  .search-page form.filters { grid-template-columns: 1fr 1fr; }
  header.site .inner { flex-wrap: wrap; }
  header.site .search { order: 3; width: 100%; max-width: 100%; }
}
