:root {
  --violet: #381883; --violet-2: #2c1268; --violet-3: #4a23a8; --purple: #8c30fe; --gold: #ffde59; --gold-ink: #2b1a00;
  --ink: #fff; --ink-2: #d9cdfa; --ink-3: #a99ad8; --paper: #fffaf0; --danger: #ff5a5a;
  --shadow: 3px 3px 0 #000; --radius: 6px;
  --ease-out: cubic-bezier(.16, 1, .3, 1); --dur: 200ms;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--violet); color: var(--ink); font: 15px/1.45 Heebo, system-ui, sans-serif; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(a, button, input, select):focus-visible { outline: none; box-shadow: 0 0 0 2px var(--violet), 0 0 0 4px var(--gold); border-radius: var(--radius); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border: 2px solid #000; border-radius: var(--radius); background: var(--purple); color: #fff; font-weight: 700;
  box-shadow: var(--shadow); text-decoration: none; white-space: nowrap; transition: transform var(--dur) var(--ease-out); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.btn--gold { background: var(--gold); color: var(--gold-ink); }
.btn--ghost { background: transparent; border-color: var(--ink-3); box-shadow: none; }
.btn--danger { background: transparent; border-color: var(--danger); color: #ffd0d0; box-shadow: none; }
.btn--sm { min-height: 34px; padding: 3px 10px; font-size: 14px; }
.btn--big { min-height: 48px; font-size: 17px; flex: 1; }
.btn:disabled { opacity: .5; cursor: progress; }

.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 10px 16px; background: var(--violet-2); border-bottom: 2px solid #000; }
.top__brand { display: flex; align-items: center; gap: 8px; }
.top__brand h1 { margin: 0; font-size: 20px; font-weight: 900; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.top__actions { display: flex; gap: 8px; }
.top__status { grid-column: 1 / -1; margin: 0; min-height: 20px; font-size: 13px; color: var(--ink-2); white-space: pre-line; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 12px 16px; }
.bar input[type="search"] { flex: 1 1 260px; height: 42px; padding: 0 12px; border: 2px solid #000; border-radius: var(--radius); background: var(--paper); color: #1a0d40; }
.bar label { display: grid; gap: 2px; font-size: 12px; color: var(--ink-3); }
.bar select, .f select { height: 42px; border: 2px solid #000; border-radius: var(--radius); background: var(--violet-3); padding: 0 8px; min-width: 130px; }
.bar__count { margin: 0 0 8px; color: var(--ink-3); font-size: 13px; }

.held { margin: 0 16px 10px; padding: 10px 12px; border: 2px dashed var(--gold); border-radius: var(--radius); display: grid; gap: 8px; }
.held p { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 0 16px 40px; }
.card { position: relative; display: grid; grid-template-rows: auto auto; padding: 0; border: 2px solid #000; border-radius: var(--radius);
  background: var(--violet-3); box-shadow: var(--shadow); overflow: hidden; text-align: start; }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #1b0b45; display: block; }
.card__t { padding: 4px 6px 6px; font-size: 13px; line-height: 1.3; min-height: 2.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card__b { position: absolute; top: 4px; inset-inline-start: 4px; display: flex; flex-wrap: wrap; gap: 3px; }
.card__b span { font-size: 11px; font-weight: 700; padding: 1px 6px; border: 1.5px solid #000; border-radius: 4px; background: var(--gold); color: var(--gold-ink); }
.card__b .b-hidden { background: var(--danger); color: #fff; }
.card__b .b-held { background: #ffb347; }
.card__b .b-removed { background: #000; color: #fff; }
.card__b .b-ready { background: #8fd3ff; }
.card.is-dim img { opacity: .55; }
@media (hover: hover) { .card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 #000; } }
.empty { text-align: center; color: var(--ink-2); }

dialog { border: 2px solid #000; padding: 0; color: var(--ink); background: var(--violet); box-shadow: 6px 6px 0 #000; border-radius: 10px; }
dialog::backdrop { background: rgba(10, 4, 30, .75); }
.ed { width: min(1280px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
.ed__bar { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px 12px; background: var(--violet-2); border-bottom: 2px solid #000; }
.ed__bar h2 { margin: 0; font-size: 17px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed__nav { display: flex; gap: 6px; }
.ed__body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 380px); gap: 16px; padding: 14px; align-items: start; }

.crop { display: grid; gap: 10px; }
.crop__stage { position: relative; justify-self: center; max-width: 100%; touch-action: none; user-select: none; background: #1b0b45; border: 2px solid #000; }
.crop__stage img { display: block; max-width: 100%; max-height: 66dvh; }
.crop__rect { position: absolute; border: 2px solid var(--gold); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); cursor: move; touch-action: none; }
.crop__stage { overflow: hidden; }
.crop__rect span { position: absolute; width: 22px; height: 22px; background: var(--gold); border: 2px solid #000; touch-action: none; }
.crop__rect span[data-h="nw"] { top: -11px; left: -11px; cursor: nwse-resize; }
.crop__rect span[data-h="ne"] { top: -11px; right: -11px; cursor: nesw-resize; }
.crop__rect span[data-h="sw"] { bottom: -11px; left: -11px; cursor: nesw-resize; }
.crop__rect span[data-h="se"] { bottom: -11px; right: -11px; cursor: nwse-resize; }
.crop__rect span[data-h="n"], .crop__rect span[data-h="s"] { left: calc(50% - 16px); width: 32px; height: 14px; cursor: ns-resize; }
.crop__rect span[data-h="n"] { top: -8px; } .crop__rect span[data-h="s"] { bottom: -8px; }
.crop__rect span[data-h="w"], .crop__rect span[data-h="e"] { top: calc(50% - 16px); width: 14px; height: 32px; cursor: ew-resize; }
.crop__rect span[data-h="w"] { left: -8px; } .crop__rect span[data-h="e"] { right: -8px; }
.crop__tools { display: grid; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
.hint, .note { margin: 0; font-size: 13px; color: var(--ink-2); }
.note { padding: 6px 8px; border: 1.5px solid var(--ink-3); border-radius: 4px; }

.seg { display: inline-flex; border: 2px solid #000; border-radius: var(--radius); overflow: hidden; background: var(--violet-3); width: max-content; max-width: 100%; flex-wrap: wrap; }
.seg button { min-height: 36px; padding: 2px 12px; border: 0; border-inline-start: 2px solid #000; background: transparent; font-weight: 700; }
.seg button:first-child { border-inline-start: 0; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }

.bright { display: grid; gap: 6px; padding: 8px 10px; border: 2px solid #000; border-radius: var(--radius); background: var(--violet-2); }
.bright__row { display: flex; align-items: center; gap: 8px; }
.bright__btns { justify-content: flex-start; }
.bright label { font-weight: 700; min-width: 4.6em; }
.bright input[type="range"] { flex: 1 1 160px; min-width: 120px; accent-color: var(--gold); }
.bright output { min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.cbadge:not(:empty) { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-inline-start: 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 13px; }
.cdlg__hint { margin: 10px 14px 0; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 14px; }
.ccard2 { padding: 0 0 8px; }
.ccard2 img { width: 100%; height: auto; aspect-ratio: auto; object-fit: contain; background: #1b0b45; cursor: zoom-in; }
.ccard2.is-big { grid-column: 1 / -1; }
.ccard2.is-big img { max-height: 70dvh; cursor: default; }
.ccard2__t { padding: 6px 8px; font-size: 13px; color: var(--ink-2); }
.ccard2 .row { padding: 0 8px; }
.fields { display: grid; gap: 12px; }
.f { display: grid; gap: 4px; }
.f > span { font-size: 13px; color: var(--ink-3); }
.f input, #tagInput, #catName { height: 42px; padding: 0 10px; border: 2px solid #000; border-radius: var(--radius); background: var(--paper); color: #1a0d40; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border: 1.5px solid #000; border-radius: 4px; background: var(--violet-3); font-size: 13px; }
.tag button { border: 0; background: transparent; padding: 0 4px; font-size: 15px; line-height: 1; }
.gmcats { display: grid; gap: 6px; }
.gmcats__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gmcats__chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border: 1.5px solid #000; border-radius: 4px; background: var(--purple); font-size: 13px; font-weight: 700; }
.gmcats__chip button { border: 0; background: transparent; padding: 0 4px; font-size: 15px; line-height: 1; }
.gmcats__add { height: 40px; border: 2px dashed var(--ink-3); border-radius: var(--radius); background: transparent; padding: 0 8px; }
.gmcats__add:disabled { opacity: .5; }
.gmcats__add option { background: var(--violet-3); }
.small select { height: 42px; border: 2px solid #000; border-radius: var(--radius); background: var(--violet-3); padding: 0 8px; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.fields__actions { display: flex; gap: 8px; }

.small { width: min(420px, calc(100vw - 32px)); padding: 18px; }
.small h2 { margin: 0 0 12px; }
.small form { display: grid; gap: 10px; }

.toast { position: fixed; inset-inline: 0; margin-inline: auto; bottom: 18px; width: max-content; max-width: calc(100vw - 32px); z-index: 50;
  background: var(--gold); color: var(--gold-ink); border: 2px solid #000; border-radius: var(--radius); padding: 8px 16px; font-weight: 700; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .ed { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; margin: 0; }
  .ed__body { grid-template-columns: 1fr; padding: 10px; }
  .crop__stage img { max-height: 48dvh; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; padding: 0 10px 30px; }
  .top__brand h1 { font-size: 17px; }
  .ed__nav .btn { padding: 4px 8px; }
  /* the phone (16.11.2026, Daniel: "I need to scroll vertically, horizontally, the buttons all over the place"):
     the action row wrapped nowhere and pushed the page to 535 px; now everything fits the width */
  .top { position: static; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 8px 10px; }
  .top__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .top__actions .btn { min-width: 0; min-height: 38px; padding: 4px 6px; gap: 4px; font-size: 13px; box-shadow: 2px 2px 0 #000; }
  .top__actions .btn img { width: 18px; height: 18px; }
  .top__actions .cbadge:not(:empty) { min-width: 18px; height: 18px; margin-inline-start: 2px; font-size: 11px; }

  .top__status { min-height: 0; }
  .bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; padding: 6px 10px 8px; align-items: end; }
  .bar input[type="search"] { grid-column: 1 / -1; height: 40px; }
  .bar select { min-width: 0; width: 100%; height: 38px; }
  .bar__count { grid-column: 1 / -1; margin: 0; }
  .grid { padding: 0 10px 30px; }
  /* the editor: Save stays in the top bar; the crop tools in tidy equal rows */
  .ed__bar { gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .ed__bar h2 { font-size: 15px; }
  .ed__bar .btn { min-height: 38px; padding: 4px 10px; font-size: 14px; }
  .ed__body { gap: 10px; padding: 8px 10px 16px; }
  .crop__tools { gap: 6px; }
  #ratios { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
  #ratios button { min-width: 0; min-height: 38px; padding: 4px 2px; font-size: 14px; }
  .crop__tools > .row:not(#autoChoices) { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .crop__tools > .row:not(#autoChoices) .btn { min-width: 0; min-height: 38px; padding: 4px 4px; font-size: 13.5px; }
  #autoBtn, #noCropBtn { grid-column: span 3; }
  #rotL, #rotR, #flipBtn { grid-column: span 2; }
  .bright { gap: 4px; padding: 6px 8px; }
  .bright input[type="range"] { min-width: 0; }
  .bright__btns .btn { min-height: 34px; }
  .crop__tools .hint { font-size: 12.5px; }
  .fields { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* online login */
.login { display: grid; place-items: center; min-height: calc(100dvh - 80px); padding: 20px; }
.login__box { display: grid; gap: 14px; justify-items: center; width: min(360px, 100%); padding: 24px; border: 2px solid #000; border-radius: 10px; background: var(--violet-2); box-shadow: 6px 6px 0 #000; }
.login__box h2 { margin: 0; font-size: 22px; font-weight: 900; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.login__box .f { width: 100%; }
.login__box .btn { width: 100%; }
.login__err { margin: 0; min-height: 1.4em; color: #ffd0d0; font-weight: 700; text-align: center; }

/* embed=1 (the site's "ניהול" button): only the editor of one meme */
.is-embed .top, .is-embed .bar, .is-embed #grid, .is-embed .held, .is-embed #empty { display: none !important; }
.is-embed { background: var(--violet); }

/* עכשיו בארץ editor */
.nowedit { display: grid; gap: 14px; padding: 14px; }
.nowquietrow { display: grid; gap: 6px; padding: 10px; border: 2px dashed var(--ink-3); border-radius: var(--radius); }
.nowquietrow input[type="text"], #nowMsg { height: 40px; padding: 0 10px; border: 2px solid #000; border-radius: var(--radius); background: var(--paper); color: #1a0d40; }
.nowtopics { display: grid; gap: 14px; }
.ntopic { display: grid; gap: 8px; padding: 12px; border: 2px solid #000; border-radius: var(--radius); background: var(--violet-2); box-shadow: var(--shadow); }
.ntopic__head { align-items: center; }
.ntopic__title { flex: 1 1 200px; height: 42px; padding: 0 10px; border: 2px solid #000; border-radius: var(--radius); background: var(--paper); color: #1a0d40; font-weight: 700; }
.ntopic__note, .ntopic__search { height: 38px; padding: 0 10px; border: 2px solid #000; border-radius: var(--radius); background: var(--paper); color: #1a0d40; }
.ntopic__state { font-size: 13px; font-weight: 700; color: var(--gold); }
.ntopic__when label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.ntopic__when input { height: 36px; border: 2px solid #000; border-radius: 4px; padding: 0 6px; background: var(--violet-3); }
.ntopic__items, .ntopic__results { display: flex; flex-wrap: wrap; gap: 6px; }
.nitem { position: relative; }
.nitem img, .nres img { width: 72px; height: 72px; object-fit: cover; border: 2px solid #000; border-radius: 4px; display: block; background: #1b0b45; }
.nitem.is-main img { outline: 3px solid var(--gold); }
.nitem__x, .nitem__main { position: absolute; top: -6px; width: 24px; height: 24px; border: 2px solid #000; border-radius: 50%; padding: 0; font-weight: 900; line-height: 1; }
.nitem__x { inset-inline-end: -6px; background: #fff; color: #000; }
.nitem__main { inset-inline-start: -6px; background: var(--violet-3); color: var(--gold); }
.nitem.is-main .nitem__main { background: var(--gold); color: var(--gold-ink); }
.nres { padding: 0; border: 0; background: none; }

/* פניות: the site's contact form (16.11.2026) */
.qlist { display: grid; gap: 12px; padding: 14px; max-width: 820px; }
.qcard { padding: 12px 14px; display: grid; gap: 8px; }
.qcard__head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.qcard__topic { font-weight: 700; color: var(--gold); }
.qcard__when, .qcard__who, .qcard__meme { margin: 0; font-size: 14px; color: var(--ink-2); }
.qcard__who a { color: var(--gold); }
.qcard__msg { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--gold); font-weight: 700; text-decoration: underline; cursor: pointer; }

/* auto-approve switch in the community dialog (16.11.2026) */
.cauto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 14px 0; padding: 10px 12px; border: 2px solid #000; border-radius: var(--radius); background: rgba(255,222,89,.10); }
.cauto p { margin: 0; flex: 1 1 260px; color: #fff; font-weight: 500; }

/* the narrowest phones: a count on "ממים מהקהילה" needs the room of two columns (16.11.2026) */
@media (max-width: 400px) {
  .top__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* suggested templates: the name can be fixed before approving */
.tname { width: 100%; min-height: 38px; padding: 0 10px; border: 2px solid #000; border-radius: 6px; font: inherit; margin: 6px 0 2px; }

/* template managers */
.tmods { display: grid; gap: 6px; margin: 0 0 14px; padding: 10px 12px; border: 2px solid #000; border-radius: 8px; background: rgba(255,255,255,.06); }
.tmods__list { display: flex; flex-wrap: wrap; gap: 8px; }
.tmod { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: rgba(255,255,255,.12); }
#tModsNick { min-height: 36px; padding: 0 10px; border: 2px solid #000; border-radius: 6px; font: inherit; }
#tModsNick { color: #1b1035; background: #fffdf5; min-width: 0; flex: 1 1 220px; }
.tmods .hint { overflow-wrap: anywhere; }
#tDlg .cdlg__hint { overflow-wrap: anywhere; white-space: normal; }
