:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-light: #ccfbf1;
  --ink: #1c2826;
  --muted: #6b7c79;
  --line: #e6ece9;
  --bg: #f4f7f6;
  --card: #ffffff;
  --accent: #f59e0b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,40,38,.04), 0 8px 24px rgba(16,40,38,.06);
  --maxw: 720px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Assistant', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100%;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  /* App-like: no rubber-band revealing the browser, smooth momentum scroll */
  overscroll-behavior-y: none;
  -webkit-overflow-scrolling: touch;
}
/* Chrome (header, tabs, nav, chips) shouldn't be selectable like a web page;
   post/comment text stays selectable. */
.topbar, .tabbar, .chips, .pager, .msg-nav, .section-head { -webkit-user-select: none; user-select: none; }
a { color: inherit; text-decoration: none; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top)) 0 0;
  box-shadow: 0 2px 12px rgba(16,40,38,.18);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,.18);
  display: grid; place-items: center;
  font-weight: 800; font-size: 19px;
}
.brand-text { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.brand-text span { font-weight: 400; opacity: .85; }

.search { flex: 1; display: flex; align-items: center; position: relative; }
.search input {
  width: 100%; border: 0; outline: 0;
  background: rgba(255,255,255,.16);
  color: #fff; font: inherit; font-size: 15px;
  padding: 9px 14px; padding-left: 40px;
  border-radius: 999px;
}
.search input::placeholder { color: rgba(255,255,255,.75); }
.search button {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: #fff; opacity: .9;
  padding: 6px; cursor: pointer; display: grid; place-items: center;
}

/* App container */
.app { max-width: var(--maxw); margin: 0 auto; padding: 16px; }
.loading, .empty {
  text-align: center; color: var(--muted); padding: 48px 16px; font-size: 15px;
}

/* Section headings */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 2px 12px;
}
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 17px; font-weight: 800; margin: 0; }
.section-head a { font-size: 13px; color: var(--teal); font-weight: 600; }

/* Forum chips (home) */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 7px; box-shadow: var(--shadow);
}
.chip .n { background: var(--teal-light); color: var(--teal-dark); border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 1px 8px; }
.chip.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* Forum grid (forums tab) */
.forum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 560px) { .forum-grid { grid-template-columns: 1fr 1fr 1fr; } }
.forum-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
  transition: transform .12s ease, box-shadow .12s ease; min-height: 92px;
}
.forum-card:active { transform: scale(.97); }
.forum-card .fc-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.forum-card .fc-meta { margin-top: auto; font-size: 12px; color: var(--muted); }
.forum-card.main { background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%); color: #fff; border: 0; grid-column: 1 / -1; min-height: auto; }
.forum-card.main .fc-meta { color: rgba(255,255,255,.85); }
.forum-card .fc-badge { font-size: 11px; font-weight: 700; color: var(--accent); }

/* Thread cards */
.thread-list { display: flex; flex-direction: column; gap: 10px; }
.thread {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.thread:active { transform: scale(.985); }
.thread .t-forum {
  display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--teal);
  background: #e6f4f1; border-radius: 999px; padding: 2px 9px; margin: 0 0 7px;
}
.thread .t-title { font-weight: 700; font-size: 16px; line-height: 1.35; margin: 0 0 4px; }
.thread .t-preview { color: var(--muted); font-size: 14px; margin: 0 0 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread .t-foot { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--teal-light);
  color: var(--teal-dark); display: grid; place-items: center; font-weight: 700; font-size: 12px;
  flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.t-author { font-weight: 600; color: var(--ink); }
.t-dot { opacity: .4; }
.t-replies { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px;
  background: var(--teal-light); color: var(--teal-dark); border-radius: 999px; padding: 2px 9px; font-weight: 700; }

/* Thread detail */
.detail-head { margin-bottom: 14px; }
.back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--teal);
  font-weight: 600; font-size: 14px; margin-bottom: 12px;
}
.post {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.post.op { border-color: var(--teal-light); }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.post-head .who { display: flex; flex-direction: column; }
.post-head .name { font-weight: 700; font-size: 14.5px; }
.post-head .when { font-size: 12px; color: var(--muted); }
/* Restricted-forum login gate */
.gate {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 22px; text-align: center; margin-top: 12px;
}
.gate-lock { font-size: 40px; line-height: 1; margin-bottom: 6px; }
.gate h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; }
.gate p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 18px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; max-width: 300px; margin: 0 auto; }
.gate-form input {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font: inherit; font-size: 15px; outline: none; text-align: right;
}
.gate-form input:focus { border-color: var(--teal); }
.gate-form .btn-primary { margin-top: 2px; }
.gate-msg { color: #b91c1c; font-size: 13px; min-height: 16px; margin: 4px 0 0; }
.forum-card.locked { opacity: .85; }
.forum-card.locked .fc-meta { color: var(--accent); font-weight: 600; }

/* Infinite-scroll sentinel */
.feed-sentinel { height: 40px; margin: 6px 0 2px; display: grid; place-items: center; }
.feed-sentinel.loading::after {
  content: ''; width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--teal);
  animation: spin .7s linear infinite;
}
.feed-sentinel.done::after { content: '• • •'; color: var(--muted); letter-spacing: 2px; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Prev/next thread navigation */
.msg-nav { display: flex; gap: 10px; margin: 12px 0; }
.msg-nav:last-child { margin-top: 18px; }
.mnav-btn {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
  transition: transform .12s ease; min-height: 44px; justify-content: center;
}
.mnav-btn:active { transform: scale(.97); }
.mnav-btn.is-disabled { opacity: .4; box-shadow: none; }
.mnav-dir { font-size: 12px; font-weight: 700; color: var(--teal); }
.mnav-title { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.post-title { font-size: 20px; font-weight: 800; line-height: 1.3; margin: 0 0 12px; }
.post-body { font-size: 15.5px; line-height: 1.7; word-break: break-word; overflow-wrap: anywhere; }
.post-body img { max-width: 100%; height: auto; border-radius: 10px; }
.post-body a { color: var(--teal); text-decoration: underline; }
.post-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--line); }

.replies-head { font-size: 15px; font-weight: 800; margin: 20px 2px 12px; display: flex; align-items: center; gap: 8px; }
.replies-head .count { background: var(--teal); color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 9px; }
.post.reply { margin-inline-start: 12px; border-inline-start: 3px solid var(--teal-light); }

/* Pagination */
.pager { display: flex; justify-content: center; gap: 10px; margin: 18px 0 4px; }
.pager button {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 20px; font: inherit; font-weight: 600; font-size: 14px; color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
}
.pager button:disabled { opacity: .4; cursor: default; }
.pager .page-info { align-self: center; font-size: 13px; color: var(--muted); }

/* Bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 50;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 18px; border-radius: 12px;
}
.tabbar a.active { color: var(--teal); }

/* Search */
.search-meta { color: var(--muted); font-size: 14px; margin: 4px 2px 14px; }
.skeleton { background: linear-gradient(90deg, #eef2f1 25%, #e3e9e7 50%, #eef2f1 75%);
  background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--radius); height: 84px; }
@keyframes sh { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---- Site comments zone (our website, NOT קהילה־נט) ---- */
.site-zone {
  margin-top: 26px; padding: 16px; border-radius: var(--radius);
  background: #fffaf2; border: 1px dashed #f0c97a;
}
.site-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: #92560a; margin-bottom: 14px;
}
.site-badge {
  background: var(--accent); color: #fff; font-weight: 800; font-size: 11px;
  padding: 2px 9px; border-radius: 999px;
}
.sc-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 10px 0 16px; }
.post.site-comment {
  position: relative; background: #fff; border: 1px solid #f0c97a;
  box-shadow: none; margin-bottom: 10px;
}
.sc-flag {
  position: absolute; top: 12px; inset-inline-start: 14px;
  font-size: 10.5px; font-weight: 800; color: var(--accent);
  letter-spacing: .3px;
}
.post.site-comment .post-body { font-size: 15px; }
.sc-del {
  position: absolute; top: 10px; inset-inline-end: 12px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 13px; line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: background .12s, color .12s, border-color .12s;
}
.sc-del:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.sc-del:disabled { opacity: .5; cursor: default; }

.composer { margin-top: 14px; }
.composer textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit; font-size: 15px; resize: vertical;
  background: #fff; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.composer-as { font-size: 12.5px; color: var(--muted); }
.composer-as a { color: var(--teal); font-weight: 600; }
.btn-primary {
  background: var(--teal); color: #fff; border: 0; border-radius: 999px;
  padding: 9px 20px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.btn-primary:disabled { opacity: .55; }
.btn-ghost {
  background: transparent; border: 0; color: var(--muted); font: inherit; font-weight: 600;
  padding: 9px 14px; cursor: pointer; border-radius: 999px;
}

/* ---- Username modal ---- */
.modal-ov {
  position: fixed; inset: 0; z-index: 100; background: rgba(16,40,38,.45);
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 20px; padding: 22px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(16,40,38,.3); animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.modal p { margin: 0 0 14px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.modal input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit; font-size: 16px; outline: none;
}
.modal input:focus { border-color: var(--teal); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
