/* ---------- Themes ----------
   Every color is a token. <html data-theme="..."> picks a theme; no attribute = follow the OS (light/dark).
   Layout uses logical properties (margin-inline, inset-inline-start, ...) so RTL languages just work. */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #efefeb;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e2e2dd;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --accent-soft: #dcebe5;
  --danger: #b3261e;
  --like: #d6336c;
  --glow: #ffd43b;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #272724;
    --text: #ecece8;
    --muted: #9a9a94;
    --border: #33332f;
    --accent: #5fb39b;
    --accent-text: #0e1f1a;
    --accent-soft: #23382f;
    --danger: #f2a49e;
    --like: #f06595;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141413;
  --surface: #1e1e1c;
  --surface-2: #272724;
  --text: #ecece8;
  --muted: #9a9a94;
  --border: #33332f;
  --accent: #5fb39b;
  --accent-text: #0e1f1a;
  --accent-soft: #23382f;
  --danger: #f2a49e;
  --like: #f06595;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

:root[data-theme="dark-orange"] {
  --bg: #15110d;
  --surface: #201914;
  --surface-2: #2a211a;
  --text: #f3ebe3;
  --muted: #a8998a;
  --border: #3a2f25;
  --accent: #f08a24;
  --accent-text: #1d1006;
  --accent-soft: #3d2814;
  --danger: #ffa8a0;
  --like: #ff6b8b;
  --glow: #ffe066;
  --shadow: 0 1px 2px rgb(0 0 0 / 45%);
  color-scheme: dark;
}

:root[data-theme="warm-light"] {
  --bg: #faf5ee;
  --surface: #fffdf9;
  --surface-2: #f3eadf;
  --text: #2a2118;
  --muted: #7a6a58;
  --border: #eadfce;
  --accent: #c2571a;
  --accent-text: #ffffff;
  --accent-soft: #f7e3d4;
  --danger: #a4231b;
  --like: #c92a5a;
  --glow: #ffb703;
  color-scheme: light;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", sans-serif;
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
img { max-width: 100%; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
/* `like this` in rich text is a highlighter: the same yellow + black in every theme. */
.rich code { background: #ffe066; color: #1c1c1a; font-size: .95em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar and navigation ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-h);
  padding-inline: 1rem;
  border-block-end: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 750; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand .logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-text); }
.stage-tag { font-size: .7rem; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .35rem; }
.nav { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .65rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: .95rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.nav .avatar { display: block; }

/* Phones: the nav becomes a bottom tab bar. (backdrop-filter would make the top bar the containing block of
   the fixed nav, so it's off here.) */
@media (max-width: 699px) {
  .topbar { backdrop-filter: none; background: var(--surface); }
  .nav {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 20;
    justify-content: space-around;
    gap: 0;
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    background: var(--surface);
    border-block-start: 1px solid var(--border);
  }
  .nav a { flex-direction: column; gap: .1rem; font-size: .7rem; padding: .3rem .5rem; border-radius: 10px; }
  body.signed-in main { padding-block-end: 5.5rem; }
}

/* ---------- Layout ---------- */

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page { display: flex; flex-direction: column; gap: 1rem; }
.narrow { max-width: 460px; margin-inline: auto; width: 100%; }
.medium { max-width: 760px; margin-inline: auto; width: 100%; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head > :first-child { flex: 1 1 16rem; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: .25rem; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: .2rem; }
.crumbs a:hover { color: var(--text); }
[dir="rtl"] .icon.flip svg { transform: scaleX(-1); }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-block-end: 1px solid var(--border); scrollbar-width: none; }
.tabs a, .tabs button {
  padding: .6rem .9rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border: 0;
  border-block-end: 2px solid transparent;
  background: none;
  border-radius: 0;
  font: inherit;
  cursor: pointer;
}
.tabs a.active, .tabs button.active { color: var(--text); border-color: var(--accent); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .icon svg { width: 40px; height: 40px; }

/* ---------- Forms and buttons ---------- */

label { font-weight: 550; font-size: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field .hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], input:not([type]), select, textarea {
  font: inherit;
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400; cursor: pointer; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font: inherit;
  font-weight: 550;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .5rem .95rem;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:disabled { opacity: .55; cursor: default; }
button.secondary, .button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.secondary:hover:not(:disabled), .button.secondary:hover { background: var(--surface-2); }
button.ghost, .button.ghost { background: transparent; color: var(--text); }
button.ghost:hover:not(:disabled), .button.ghost:hover { background: var(--surface-2); }
button.danger { background: transparent; color: var(--danger); border-color: var(--border); }
button.small, .button.small { padding: .3rem .6rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 400; }
.icon-button { padding: .35rem; background: transparent; color: var(--muted); border-radius: 999px; }
.icon-button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }

.icon { display: inline-flex; flex-shrink: 0; }
.icon.filled svg { fill: currentColor; }

/* Toggle buttons: like and want */
.toggle { background: var(--surface); color: var(--text); border-color: var(--border); }
.toggle.like[aria-pressed="true"] { color: var(--like); border-color: color-mix(in srgb, var(--like) 40%, var(--border)); background: color-mix(in srgb, var(--like) 10%, var(--surface)); }
.toggle.want[aria-pressed="true"] { color: var(--accent-text); background: var(--accent); }
.toggle.big { padding: .7rem 1.2rem; font-size: 1.05rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  font-weight: 450;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.badge { display: inline-flex; align-items: center; padding: .05rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 550; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Toasts and modals ---------- */

.toasts { position: fixed; inset-inline: 0; inset-block-end: 5rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 100; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: min(92vw, 520px); }
.toast.error { background: var(--danger); color: #fff; }

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: min(94vw, 520px);
  max-height: 90vh;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
.modal.wide { width: min(96vw, 900px); }
.modal::backdrop { background: rgb(0 0 0 / 45%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem .85rem 1.25rem; border-block-end: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1.25rem; overflow: auto; }

.editor-overlay { position: fixed; inset: 0; z-index: 90; background: rgb(0 0 0 / 70%); display: flex; flex-direction: column; }
.editor-overlay iframe { flex: 1; width: 100%; border: 0; background: #111; }

/* ---------- Rich text and copy ---------- */

.rich p { margin: 0 0 .5rem; }
.rich p:last-child { margin-block-end: 0; }
.rich ul { margin: 0 0 .5rem; padding-inline-start: 1.25rem; }
.rich a { overflow-wrap: anywhere; }
.copyable { overflow-wrap: anywhere; }
span.copyable, span.copyable > .rich { display: inline; }
.copy-button { display: inline-flex; vertical-align: middle; padding: .15rem; margin-inline-start: .25rem; background: none; border: 0; color: var(--muted); opacity: .7; border-radius: 6px; }
.copy-button:hover { opacity: 1; color: var(--accent); background: var(--surface-2); }
.copy-button svg { width: 15px; height: 15px; }

/* ---------- Avatars ---------- */

.avatar { border-radius: 50%; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.avatars { display: flex; align-items: center; }
.avatars .avatar { border: 2px solid var(--surface); margin-inline-start: -6px; }
.avatars .avatar:first-child { margin-inline-start: 0; }
.avatars .more { margin-inline-start: .35rem; font-size: .8rem; color: var(--muted); }
.queue { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.queue li { display: flex; align-items: center; gap: .35rem; padding: .2rem .55rem .2rem .25rem; border: 1px solid var(--border); border-radius: 999px; font-size: .85rem; }
.queue li.me { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Campaign list ---------- */

.campaign-tile { display: flex; flex-direction: column; gap: .5rem; text-decoration: none; color: var(--text); transition: transform .12s, border-color .12s; }
.campaign-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.campaign-tile h2 { margin: 0; }

/* ---------- Image gallery with item markers ---------- */

.gallery { position: relative; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.gallery-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; min-height: 220px; padding: .5rem; }
/* The image keeps its aspect ratio: width and height are both auto, so a max-width or max-height scales both
   (the width/height attributes only reserve the shape while it loads). The frame hugs the image, so markers
   (in % of the frame) land on the right spot. */
.frame { position: relative; display: inline-block; line-height: 0; max-width: 100%; }
.frame img { display: block; width: auto; height: auto; max-width: 100%; max-height: min(62vh, 560px); border-radius: 6px; }
.gallery.compact .frame img { max-height: 320px; }
.gallery.picker .frame { cursor: crosshair; }
.frame.zoomable { cursor: zoom-in; }

/* Full-screen image viewer (lightbox) */
.lightbox { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; color: #fff; overflow: hidden; }
.lightbox::backdrop { background: rgb(0 0 0 / 70%); }
.lightbox-view { position: absolute; inset: 0; display: flex; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; scrollbar-width: thin; }
/* margin: auto centers it, and (unlike centering with align/justify) still lets every edge scroll into view. */
.lightbox-frame { position: relative; margin: auto; line-height: 0; flex-shrink: 0; }
.lightbox-frame img { display: block; width: auto; height: auto; max-width: 100vw; max-height: 100vh; max-height: 100dvh; user-select: none; }
.lightbox-view.zoomed .lightbox-frame img { max-width: none; max-height: none; }
.lightbox-view.zoomed { cursor: zoom-out; }
.lightbox-frame.picker { cursor: crosshair; }
.lightbox-bar { position: absolute; inset-block-start: 0; inset-inline: 0; display: flex; align-items: center; justify-content: flex-end; gap: .4rem; padding: .6rem; padding-block-start: calc(.6rem + env(safe-area-inset-top)); pointer-events: none; }
.lightbox-bar > * { pointer-events: auto; }
.lightbox-count { margin-inline-end: auto; padding: .2rem .6rem; border-radius: 999px; background: rgb(0 0 0 / 55%); font-size: .85rem; }
.lightbox-count:empty { visibility: hidden; }
.lightbox-button { padding: .5rem; border-radius: 999px; background: rgb(0 0 0 / 55%); color: #fff; border: 1px solid rgb(255 255 255 / 25%); }
.lightbox-button:hover:not(:disabled) { background: rgb(0 0 0 / 75%); }
.lightbox-nav { position: absolute; inset-block-start: 50%; transform: translateY(-50%); }
.lightbox-nav.prev { inset-inline-start: .6rem; }
.lightbox-nav.next { inset-inline-end: .6rem; }
.gallery-nav { position: absolute; inset-block-start: 50%; transform: translateY(-50%); background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: .3rem; }
.gallery-nav.prev { inset-inline-start: .5rem; }
.gallery-nav.next { inset-inline-end: .5rem; }
.gallery-dots { position: absolute; inset-block-end: .4rem; inset-inline: 0; display: flex; justify-content: center; gap: .3rem; pointer-events: none; }
.gallery-dots span { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--text) 30%, transparent); }
.gallery-dots span.on { background: var(--accent); }
.gallery-expand { position: absolute; inset-block-start: .5rem; inset-inline-end: .5rem; background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: .3rem; }
.gallery-count {position: absolute; inset-block-start: .5rem; inset-inline-end: .5rem; }

/* "This is the item": a ring with an animated glow and no fill, so the thing under it stays visible.
   Positions are physical (image coordinates), not logical. */
.marker {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: transparent;
  border: 3px solid var(--glow);
  box-shadow: 0 0 6px 2px color-mix(in srgb, var(--glow) 70%, transparent), inset 0 0 6px 1px color-mix(in srgb, var(--glow) 60%, transparent);
  animation: glow 1.6s ease-in-out infinite;
  pointer-events: none;
}
/* Other items' spots (in the editor): a thin, still ring. */
.marker.dim { border-width: 2px; border-color: rgb(255 255 255 / 70%); width: 18px; height: 18px; animation: none; box-shadow: 0 0 0 1px rgb(0 0 0 / 35%); }
@keyframes glow {
  50% {
    box-shadow: 0 0 18px 7px color-mix(in srgb, var(--glow) 55%, transparent), inset 0 0 10px 3px color-mix(in srgb, var(--glow) 45%, transparent);
    transform: translate(-50%, -50%) scale(1.12);
  }
}
@media (prefers-reduced-motion: reduce) { .marker { animation: none; } }

/* ---------- Item cards (campaign page) ----------
   Phone: images on top, item info rows under them. Wide screens: image column + info column side by side,
   and the images stay in view while the info scrolls. */

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.meta-card { display: grid; gap: 1rem; padding: 1rem; }
.meta-card .meta-images { min-width: 0; }
.meta-card .meta-info { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
@media (min-width: 760px) {
  .meta-card { grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); align-items: start; padding: 1.25rem; }
  .meta-card .meta-images { position: sticky; inset-block-start: calc(var(--topbar-h) + 1rem); }
}
.item-row { display: flex; flex-direction: column; gap: .45rem; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.item-row.highlight { border-color: var(--accent); }
.item-row h3 a { color: var(--text); text-decoration: none; }
.item-row h3 a:hover { color: var(--accent); }
/* Card details: one per line, each with a small dot. */
.fast-props { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
.fast-props li { position: relative; padding-inline-start: .9rem; }
.fast-props li::before { content: ""; position: absolute; inset-inline-start: .15rem; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.fast-props .prop-name { color: var(--muted); }
/* A rich text value starts on the name's line; its later lines line up under its first. */
.fast-props li:has(> div.copyable) { display: flex; gap: .3rem; align-items: baseline; }
.fast-props li > div.copyable { flex: 0 1 auto; min-width: 0; }
.item-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.item-actions .more { margin-inline-start: auto; }

/* ---------- Item page ---------- */

/* Images across the full width on top (a common hero size: about half the screen height, 280-560px), then the
   details. On wide screens the details sit in two columns: the item itself, then other items + Q&A. */
.gallery.hero .slide { min-height: clamp(280px, 50vh, 560px); }
.gallery.hero .frame img { max-height: clamp(280px, 50vh, 560px); }
.item-body { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 900px) {
  .item-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.props-table { width: 100%; border-collapse: collapse; }
.props-table th, .props-table td { text-align: start; vertical-align: top; padding: .5rem .25rem; border-block-end: 1px solid var(--border); }
.props-table th { width: 38%; color: var(--muted); font-weight: 500; }
.props-table tr:last-child th, .props-table tr:last-child td { border-block-end: 0; }
/* Rich text gets the whole width: name on top, value under it. */
.props-table tr.stacked .prop-name { color: var(--muted); font-weight: 500; margin-block-end: .3rem; }
.bool-yes { color: var(--accent); font-weight: 600; }

/* ---------- Q&A ---------- */

.qna { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.qna li { padding: .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); display: flex; flex-direction: column; gap: .4rem; }
.qna .q { font-weight: 600; display: flex; gap: .5rem; align-items: flex-start; }
.qna .a { display: flex; gap: .5rem; align-items: flex-start; }
.qna .label { font-weight: 800; color: var(--accent); display: inline-flex; align-items: center; flex-shrink: 0; }
.qna .label .copy-button { margin-inline-start: .1rem; }
.with-icon { display: flex; align-items: center; gap: .4rem; }
.with-icon .icon { color: var(--accent); }

/* ---------- Messages ---------- */

.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-list a { display: flex; align-items: center; gap: .75rem; padding: .8rem .25rem; border-block-end: 1px solid var(--border); text-decoration: none; color: var(--text); }
.thread-list a:hover { background: var(--surface-2); }
.messages { display: flex; flex-direction: column; gap: .5rem; }
.bubble { max-width: min(80%, 560px); padding: .55rem .8rem; border-radius: 14px; background: var(--surface-2); align-self: flex-start; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--accent-soft); }
.bubble time { display: block; font-size: .72rem; color: var(--muted); margin-block-start: .2rem; }
/* The message box gets the full width; Send sits under it. */
.composer { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; }
.composer textarea { min-height: 2.8rem; height: 2.8rem; }

/* ---------- Studio ---------- */

.credit-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.credit-bar span { display: block; height: 100%; background: var(--accent); }
.image-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.image-tile { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; background: var(--surface-2); padding: 0; aspect-ratio: 1; cursor: pointer; }
.image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-tile[aria-pressed="true"] { border-color: var(--accent); }
.image-tile .badge { position: absolute; inset-block-start: .3rem; inset-inline-start: .3rem; }
.image-tile .tick { position: absolute; inset-block-start: .3rem; inset-inline-end: .3rem; background: var(--accent); color: var(--accent-text); border-radius: 50%; display: none; padding: 2px; }
.image-tile[aria-pressed="true"] .tick { display: inline-flex; }
.thumbs { display: flex; gap: .35rem; flex-wrap: wrap; }
.thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; }
.thumbs.small-thumbs { align-items: center; margin-block-start: .3rem; text-decoration: none; }
.thumbs.small-thumbs img { width: 40px; height: 40px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-block-end: 1px solid var(--border); flex-wrap: wrap; }
.list > li:last-child { border-block-end: 0; }
.group-picker { width: auto; flex: 0 1 15rem; }
.group-tags { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.badge.tag { gap: .15rem; padding-inline-end: .2rem; color: var(--text); }
.tag-x { display: inline-flex; padding: 1px; border: 0; background: none; color: var(--muted); border-radius: 50%; cursor: pointer; }
.tag-x:hover { color: var(--danger); background: var(--surface); }
.tag-x svg { width: 13px; height: 13px; }
.bulk-bar { padding: .5rem .75rem; border-radius: var(--radius-sm); background: var(--accent-soft); }
.bulk-bar.idle { background: var(--surface-2); color: var(--muted); }
.item-queue { padding-top: .1rem; }
.status-set { padding-block: .75rem; border-block-end: 1px solid var(--border); }
.status-set:last-child { border-block-end: 0; }
.list > li.link-row { flex-direction: column; align-items: stretch; gap: .4rem; }
.list > li.link-row.off input { opacity: .6; }
.source { display: inline-flex; align-items: center; gap: .25rem; }
.source svg { width: 14px; height: 14px; }
.prop-row { display: grid; gap: .4rem; grid-template-columns: minmax(0, 1.2fr) 7.5rem minmax(0, 2fr) auto auto; align-items: center; }
.prop-row textarea { min-height: 2.6rem; }
.item-editor { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--bg); }
/* Phones: the name gets its own row, then type / "On card" / remove, then the value. The item title too. */
@media (max-width: 699px) {
  .prop-row { grid-template-columns: minmax(0, 1fr) auto auto; padding-block-end: .6rem; border-block-end: 1px dashed var(--border); }
  .prop-row > :first-child { grid-column: 1 / -1; }
  .prop-row .prop-value { grid-column: 1 / -1; grid-row: 3; }
  .item-editor-head > .field { flex-basis: 100%; }
}
.stats { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.stats span { display: inline-flex; align-items: center; gap: .25rem; }
.stats svg { width: 15px; height: 15px; }
.tree { list-style: none; margin: 0; padding-inline-start: 1rem; border-inline-start: 2px solid var(--border); }
.tree > li { padding: .4rem 0; }

/* ---------- Tables (admin) ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: start; padding: .5rem; border-block-end: 1px solid var(--border); vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 550; white-space: nowrap; }
table.data input[type="number"] { width: 6rem; }

/* ---------- Map ---------- */

.map { width: 100%; height: 220px; border: 0; border-radius: var(--radius-sm); background: var(--surface-2); }

/* Map picker (components/location.js): OpenStreetMap tiles we place ourselves, drag to move, click to pick. */
.map-picker { position: relative; height: 280px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-2); touch-action: none; cursor: crosshair; user-select: none; }
.map-picker.dragging { cursor: grabbing; }
.map-picker .tiles img { position: absolute; width: 256px; height: 256px; max-width: none; pointer-events: none; }
.map-picker .map-pin { position: absolute; width: 0; height: 0; pointer-events: none; color: var(--danger); }
.map-picker .map-pin .icon { position: absolute; transform: translate(-50%, -100%); filter: drop-shadow(0 1px 2px rgb(0 0 0 / 45%)); }
.map-picker .map-pin svg { width: 34px; height: 34px; fill: currentColor; stroke: #fff; }
.map-picker .map-pin svg circle { fill: #fff; stroke: none; }
.map-picker .map-zoom { position: absolute; inset-block-start: .5rem; inset-inline-end: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.map-picker .map-zoom button { width: 2rem; height: 2rem; padding: 0; justify-content: center; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.map-picker .map-credit { position: absolute; inset-block-end: 0; inset-inline-end: 0; font-size: .7rem; padding: .05rem .35rem; background: rgb(255 255 255 / 80%); color: #333; }
.map-picker .map-credit a { color: inherit; }

/* JSON viewer (admin raw view) */
.json-view { font-size: .85rem; overflow-wrap: anywhere; }
.json-view dl { display: grid; grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr); gap: .2rem .75rem; margin: 0; }
.json-view dt { color: var(--muted); font-family: ui-monospace, monospace; }
.json-view dd { margin: 0; min-width: 0; }
.json-view details { border-inline-start: 2px solid var(--border); padding-inline-start: .6rem; margin-block: .15rem; }
.json-view summary { cursor: pointer; color: var(--muted); }
.json-view .null { color: var(--muted); font-style: italic; }
.json-view .num, .json-view .bool { color: var(--accent); font-family: ui-monospace, monospace; }
.json-view img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; }
.json-view pre { white-space: pre-wrap; margin: 0; font: inherit; }

/* Campaigns that were stopped */
.campaign-tile.inactive { opacity: .7; }
.section-title { margin: 2rem 0 .75rem; font-size: 1.05rem; color: var(--muted); }
.notice { display: flex; gap: .5rem; align-items: center; padding: .6rem .85rem; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }

/* Profile header: avatar, name + email, sign out. Phones: sign out goes under them. */
.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem .75rem; }
@media (max-width: 699px) {
  .profile-head { grid-template-columns: auto minmax(0, 1fr); }
  .profile-head > button { grid-column: 1 / -1; justify-self: start; }
}

/* Settings footer: versions */
.version-info { margin: 1.5rem 0 0; padding: 0; list-style: none; text-align: center; color: var(--muted); font-size: .8rem; }

/* Privacy link + analytics switch above the version footer (Settings) */
.legal-links { margin: 1.5rem 0 0; text-align: center; color: var(--muted); }

/* Analytics (cookie) banner, pinned to the bottom until answered. The button stays beside the text, at every width. */
.consent {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: .75rem 16px calc(.75rem + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow);
}
.consent p { margin: 0; max-width: 60ch; font-size: .9rem; }
.consent > button { flex-shrink: 0; }
/* The ring on "Accept" fills up over 10 s, then the banner accepts by itself (consent.js listens for animationend).
   Hovering or focusing the banner pauses it. */
.consent .countdown { width: 1.1em; height: 1.1em; transform: rotate(-90deg); }
.consent .countdown circle { fill: none; stroke: currentColor; stroke-width: 3; }
.consent .countdown .track { opacity: .3; }
.consent .countdown .fill { stroke-dasharray: 100; stroke-dashoffset: 100; animation: consent-countdown 10s linear forwards; }
.consent:hover .countdown .fill, .consent:focus-within .countdown .fill { animation-play-state: paused; }
@keyframes consent-countdown { to { stroke-dashoffset: 0; } }
@media (max-width: 699px) {
  .consent { gap: .6rem; padding-block: .5rem calc(.5rem + env(safe-area-inset-bottom)); }
  .consent p { font-size: .78rem; line-height: 1.35; }
  .consent > button { padding: .4rem .7rem; font-size: .85rem; }
}
