/* ארכיון @orcarmi: dark by default, light on request (data-theme on <html>). */
:root {
  color-scheme: dark;
  --bg: #101012;
  --bg-blur: rgba(16, 16, 18, 0.82);
  --surface: #18181b;
  --surface-2: #202024;
  --border: #26262b;
  --border-strong: #36363d;
  --text: #ececef;
  --text-2: #b9b9c1;
  --muted: #8a8a93;
  --accent: #6aa6ff;
  --accent-weak: rgba(106, 166, 255, 0.14);
  --mark: rgba(250, 204, 21, 0.3);
  --target: rgba(106, 166, 255, 0.09);
  --rail: #34343b;
  --avatar-a: #3d5a8c;
  --avatar-b: #7a4f9a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-blur: rgba(255, 255, 255, 0.86);
  --surface: #f6f6f8;
  --surface-2: #eeeef1;
  --border: #e7e7eb;
  --border-strong: #d3d3da;
  --text: #0f0f12;
  --text-2: #3b3b44;
  --muted: #6c6c76;
  --accent: #1c5fd4;
  --accent-weak: rgba(28, 95, 212, 0.09);
  --mark: #fde68a;
  --target: rgba(28, 95, 212, 0.06);
  --rail: #dadae0;
  --avatar-a: #4a6fb0;
  --avatar-b: #8f5cb8;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 8px; top: -40px; background: var(--accent); color: #fff; padding: 6px 10px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 8px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-blur);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--avatar-b)); position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; inset-inline: 6px; height: 2.5px; border-radius: 2px; background: #fff; }
.brand-mark::before { top: 8px; }
.brand-mark::after { top: 14px; inset-inline-end: 11px; }
.bar-actions { display: flex; gap: 2px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: none; border: 0; cursor: pointer; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 17px; height: 17px; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }

.search { display: flex; gap: 8px; align-items: center; padding: 4px 0 8px; }
.search-box {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 14px; height: 40px; color: var(--muted);
}
.search-box:focus-within { border-color: var(--accent); background: var(--bg); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; color: var(--text); }
.search-box input::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.6; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; flex: none; }
.seg button { border: 0; background: none; padding: 0 12px; height: 32px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 14px; }
.seg button[aria-checked="true"] { background: var(--text); color: var(--bg); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 0 10px; }
.filters select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a93' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat left 8px center / 14px;
  border: 1px solid var(--border); border-radius: 999px; height: 32px; padding: 0 12px 0 28px; font-size: 13.5px; cursor: pointer;
}
.stat { color: var(--muted); font-size: 13px; margin-inline-start: auto; }
body:not(.route-feed) .filters { display: none; }

/* Boot */
.boot { text-align: center; color: var(--muted); padding: 18vh 0; }
.spinner { width: 28px; height: 28px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; max-width: 240px; margin: 10px auto 0; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* Feed */
.feed { padding-bottom: 40px; }
.card { border-bottom: 1px solid var(--border); padding: 6px 0 8px; }
.card-chip { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; padding: 10px 0 0; padding-inline-start: 52px; }
.card-chip svg { width: 15px; height: 15px; }
.more {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 8px; padding-inline-start: 52px;
  color: var(--accent); font-size: 14px; font-weight: 550;
}
.more:hover { text-decoration: underline; }
.gap { padding-inline-start: 52px; color: var(--muted); font-size: 13px; padding-block: 2px 6px; }
.empty, .end { text-align: center; color: var(--muted); padding: 48px 0; }
.end { padding: 28px 0 60px; font-size: 13.5px; }
.sentinel { height: 1px; }
.notice { margin: 14px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 14px; }
.notice .progress { max-width: none; margin: 10px 0 2px; }
.notice small { color: var(--muted); }

/* Post */
.post { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px; padding: 12px 0 2px; position: relative; }
.card .post { cursor: pointer; }
.rail { position: relative; display: flex; justify-content: center; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(140deg, var(--avatar-a), var(--avatar-b));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; user-select: none;
}
.post.has-next .rail::after { content: ""; position: absolute; top: 44px; bottom: -10px; width: 2px; border-radius: 2px; background: var(--rail); }
.post.target { background: var(--target); border-radius: var(--radius); margin-inline: -10px; padding-inline: 10px; }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; line-height: 1.35; font-size: 14.5px; }
.name { font-weight: 700; }
.handle, .dot, .time { color: var(--muted); }
.time:hover { text-decoration: underline; }
.replying { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.replying bdi { color: var(--accent); }
.badges { display: inline-flex; gap: 4px; }
.badge { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.post-title { font-size: 18px; line-height: 1.4; margin: 6px 0 2px; font-weight: 750; }
.cats { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; }
.text a, .ref-text a, .about a { color: var(--accent); }
.text a:hover, .about a:hover { text-decoration: underline; }
.mention, .tag { color: var(--accent); }
.empty-text { color: var(--muted); font-size: 14px; font-style: italic; }
.expand { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 550; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.ref { display: block; border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; margin-top: 8px; font-size: 14.5px; color: var(--text-2); background: none; }
.ref { cursor: pointer; }
.ref[data-href]:hover { background: var(--surface); }
.ref-head { color: var(--muted); font-size: 13px; margin-bottom: 1px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.ref-open { margin-inline-start: auto; color: var(--accent); font-size: 12.5px; }
.ref-open:hover { text-decoration: underline; }
.ref-head bdi { color: var(--text); font-weight: 600; }
.ref-text { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.ref.open .ref-text { -webkit-line-clamp: unset; display: block; }
.ref.reply-ctx { margin: 6px 0 4px; }
.article { border-inline-start: 3px solid var(--border-strong); padding-inline-start: 12px; margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }

.media { display: grid; gap: 3px; margin-top: 10px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.media button { border: 0; padding: 0; margin: 0; background: var(--surface-2); cursor: zoom-in; position: relative; display: block; min-height: 0; }
.media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media.n1 img { max-height: 560px; object-fit: contain; height: auto; }
.media.n2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; }
.media.n3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 9; }
.media.n3 > :first-child { grid-row: span 2; }
.media.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 10; }
.media.grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 160px; }
.media .plus { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 22px; font-weight: 700; }
.missing { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 90px; color: var(--muted); font-size: 13px; background: var(--surface); }
.media.n1 .missing { min-height: 70px; }

.actions { display: flex; align-items: center; gap: 2px; margin: 2px -8px 4px; }
.actions .src { font-size: 12.5px; color: var(--muted); padding-inline: 6px; }
.actions .src:hover { color: var(--text); }

/* Thread page */
.thread-head { display: flex; align-items: center; gap: 10px; padding: 14px 0 6px; border-bottom: 1px solid var(--border); }
.thread-head h1 { font-size: 18px; margin: 0; line-height: 1.3; }
.thread-head .sub { color: var(--muted); font-size: 13px; }
.thread-head .grow { flex: 1; min-width: 0; }
.thread { padding-bottom: 30vh; }
.thread .post { padding-top: 14px; }

/* About */
.about { padding: 18px 0 60px; }
.about h1 { font-size: 22px; margin: 4px 0 10px; }
.about h2 { font-size: 16px; margin: 24px 0 6px; }
.about p, .about li { color: var(--text-2); }
.about ul { padding-inline-start: 20px; }
.about dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 10px 0; }
.about dt { color: var(--muted); }
.about dd { margin: 0; font-variant-numeric: tabular-nums; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.92); display: grid; place-items: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 94vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lightbox img { max-width: 94vw; max-height: 84vh; object-fit: contain; border-radius: 6px; }
.lightbox figcaption { color: #bbb; font-size: 13px; max-width: 70ch; text-align: center; }
.lightbox .icon-btn { position: absolute; color: #ddd; background: rgba(255, 255, 255, 0.08); width: 44px; height: 44px; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.lb-close { top: 14px; inset-inline-end: 14px; }
.lb-prev { inset-inline-start: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { inset-inline-end: 14px; top: 50%; transform: translateY(-50%); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  body { font-size: 15px; }
  .post { grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; }
  .avatar { width: 34px; height: 34px; font-size: 14px; }
  .post.has-next .rail::after { top: 40px; }
  .card-chip, .more, .gap { padding-inline-start: 44px; }
  .seg button { padding: 0 10px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
  .filters::-webkit-scrollbar { display: none; }
  .filters select { flex: none; }
  .stat { flex: none; margin-inline-start: 4px; }
  .media.grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 130px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
