/* Mini App модерации WWI Memes (по прототипу docs/miniapp-prototype, вариант A).
   Цвета только из темы Telegram (--tg-theme-*): внутри Telegram их ставит telegram-web-app.js,
   вне его — заглушка в app.js. */
:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #000);
  --hint: var(--tg-theme-hint-color, #999);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #efeff3);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --section-head: var(--tg-theme-section-header-text-color, #6d6d72);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --sep: color-mix(in srgb, var(--hint) 28%, transparent);
  --ok: #2fb35a;
  --warn: #e8930c;
  --bad: #e5484d;
  --r: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.4 var(--font);
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--link); text-decoration: none; }
.hint { color: var(--hint); }
.small { font-size: 13px; }

/* --- заглушка оболочки Telegram (вне Telegram) --- */
.tg-head {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 12px;
  background: var(--tg-theme-header-bg-color, var(--bg));
  border-bottom: 1px solid var(--sep);
}
.tg-head .tg-back, .tg-head .tg-close { width: 34px; height: 34px; border-radius: 50%; font-size: 20px; color: var(--link); }
.tg-head .tg-title { flex: 1; text-align: center; font-weight: 600; }
.tg-head .tg-title small { display: block; font-weight: 400; color: var(--hint); font-size: 12px; margin-top: -2px; }
.tg-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--sep);
}
.tg-bottom[hidden] { display: none; }
.tg-btn {
  flex: 1; height: 48px; border-radius: 12px; font-weight: 600;
  background: var(--button); color: var(--button-text);
}
.tg-btn.secondary { background: var(--bg2); color: var(--danger); flex: 0 0 auto; padding: 0 18px; }
.tg-btn[hidden] { display: none; }
.tg-btn:disabled { opacity: .45; }

/* --- общий каркас --- */
#app { min-height: 100%; padding-bottom: 96px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); padding: 10px 12px 8px;
  border-bottom: 1px solid var(--sep);
}
body.mock .topbar { top: 52px; }
.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 2px; }
.seg button { flex: 1; height: 32px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--hint); }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg .count { color: var(--hint); font-weight: 400; margin-left: 4px; }
.toprow { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 9px; border-radius: 12px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  background: var(--bg2); color: var(--hint);
}
.chip.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.chip.accent { background: color-mix(in srgb, var(--button) 14%, transparent); color: var(--accent); }
.chip.solid { background: rgba(0,0,0,.55); color: #fff; backdrop-filter: blur(6px); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.section-title {
  padding: 18px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .02em;
  color: var(--section-head); display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.section-title .chip, .day .section-title span, .cal-day .section-title span { text-transform: none; letter-spacing: 0; }
.section-title b { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); font-weight: 600; }
.section { background: var(--section); border-radius: var(--r); margin: 0 10px; overflow: hidden; }
.section + .section { margin-top: 10px; }
.row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; min-height: 52px; }
.row + .row { border-top: 1px solid var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- фото и спойлер --- */
.photo { position: relative; background: #111; overflow: hidden; }
.photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.photo .over { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.photo.spoiler img { filter: blur(26px) brightness(.8); transform: scale(1.12); }
.photo .spoiler-cover {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  background-image: radial-gradient(rgba(255,255,255,.35) 1px, transparent 1.2px);
  background-size: 7px 7px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.photo .spoiler-cover span { background: rgba(0,0,0,.45); padding: 6px 12px; border-radius: 16px; }

/* --- вариант A: лента по дням --- */
.day { margin-top: 4px; }
.day-sub { padding: 0 16px 8px; font-size: 13px; color: var(--hint); }
.slotline { display: flex; gap: 6px; padding: 0 16px 10px; }
.slotpill {
  flex: 1; height: 30px; border-radius: 8px; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px dashed var(--sep); color: var(--hint); background: transparent;
}
.slotpill.full { border-style: solid; border-color: transparent; background: var(--section); color: var(--text); }
.slotpill img { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; }

.card { background: var(--section); border-radius: var(--r); margin: 0 10px 12px; overflow: hidden; }
.card .photo { max-height: 62vh; aspect-ratio: var(--ar, 4/3); }
.card-body { padding: 12px 14px 4px; }
.card-caption {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  margin: 0 0 10px;
}
.card-actions { display: flex; gap: 8px; padding: 6px 10px 12px; }
.btn {
  height: 40px; padding: 0 14px; border-radius: 10px; font-weight: 600; font-size: 14.5px;
  background: var(--bg2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--button); color: var(--button-text); flex: 1; }
.btn.ghost { background: transparent; color: var(--link); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 40px; padding: 0; font-size: 20px; }

/* --- карточка черновика целиком (детали A и экран B) --- */
.full .photo { height: 46vh; min-height: 240px; }
.full .photo.tall { height: 58vh; }
.edit-wrap { padding: 12px 14px 10px; }
.caption-edit {
  width: 100%; border: 0; outline: 0; resize: none; overflow: hidden;
  background: transparent; color: var(--text); font: 16px/1.45 var(--font); padding: 0; margin: 0;
}
.caption-edit:focus { background: color-mix(in srgb, var(--button) 6%, transparent); border-radius: 6px; }
.suffix { color: var(--hint); margin-top: 2px; }
.counter { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px 12px; font-size: 13px; color: var(--hint); }
.counter .num.warn { color: var(--warn); font-weight: 600; }
.counter .num.bad { color: var(--bad); font-weight: 600; }
.problems { padding: 0 14px 10px; color: var(--bad); font-size: 13px; }
.meter { height: 3px; background: var(--bg2); margin: 0 14px; border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--button); }
.meter i.warn { background: var(--warn); }
.meter i.bad { background: var(--bad); }

.claim { display: flex; gap: 10px; padding: 9px 14px; align-items: flex-start; }
.claim + .claim { border-top: 1px solid var(--sep); }
.claim .mark { width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.claim .mark.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.claim .mark.no { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.claim .note { font-size: 13px; color: var(--hint); margin-top: 2px; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; padding: 12px 14px; font-size: 14px; }
.kv dt { color: var(--hint); }
.kv dd { margin: 0; }
.linkrow { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }
.linkrow a { font-size: 13px; padding: 4px 10px; border-radius: 12px; background: var(--bg2); }

.switch { position: relative; width: 50px; height: 30px; flex: 0 0 50px; border-radius: 15px; background: var(--bg2); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(20px); }

.when { padding: 4px 14px 12px; }
.when-day { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.when-day > span { width: 72px; flex: 0 0 72px; font-size: 13px; color: var(--hint); }
.when-day.target > span { color: var(--ok); font-weight: 600; }
.when-day > i { flex: 1; max-width: 88px; }
.when button { flex: 1; max-width: 88px; height: 34px; border-radius: 10px; background: var(--bg2); font-size: 14px; font-weight: 500; }
.when button.on { background: var(--button); color: var(--button-text); }

.decided { margin: 12px 10px; padding: 12px 14px; border-radius: var(--r); background: var(--section); display: flex; gap: 10px; align-items: center; }

/* --- календарь --- */
.cal-day .section-title b small { font-weight: 400; color: var(--hint); font-size: 13px; }
.slot { display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-height: 64px; }
.slot + .slot { border-top: 1px solid var(--sep); }
.slot .time { width: 46px; font-weight: 600; font-variant-numeric: tabular-nums; }
.slot .thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #222; flex: 0 0 48px; }
.slot.empty .thumb { background: transparent; border: 1.5px dashed var(--sep); display: grid; place-items: center; color: var(--hint); font-size: 22px; }
.slot.picked { background: color-mix(in srgb, var(--button) 12%, transparent); outline: 2px solid var(--button); outline-offset: -2px; border-radius: 10px; }
.slot.target { background: color-mix(in srgb, var(--button) 5%, transparent); }
.slot.past { opacity: .5; }
.movebar {
  position: sticky; top: 58px; z-index: 15; margin: 8px 10px 0; padding: 10px 14px; border-radius: 12px;
  background: var(--button); color: var(--button-text); display: flex; align-items: center; justify-content: space-between; font-size: 14px;
}
body.mock .movebar { top: 110px; }
.pause-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* --- нижние листы --- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 86vh; overflow: auto;
  background: var(--bg2); border-radius: 16px 16px 0 0; padding: 8px 0 calc(84px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
body.in-tg .sheet { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 6px; }
.sheet h3 { margin: 6px 16px 4px; font-size: 17px; }
.sheet .sub { margin: 0 16px 10px; color: var(--hint); font-size: 13.5px; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; }
.reasons button { padding: 9px 14px; border-radius: 18px; background: var(--section); font-size: 14.5px; }
.reasons button.on { background: var(--button); color: var(--button-text); }
.sheet textarea {
  display: block; width: calc(100% - 32px); margin: 0 16px; min-height: 96px; padding: 10px 12px;
  border-radius: 12px; border: 0; outline: 0; resize: vertical;
  background: var(--section); color: var(--text); font: 15px/1.4 var(--font);
}
.pick-list .row { cursor: pointer; }
.pick-list img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 60;
  background: rgba(30,30,30,.94); color: #fff; border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px;
  animation: up .2s ease-out;
}
body.in-tg .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
.toast button { color: #8cc8ff; font-weight: 600; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--hint); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }

/* --- пост как в канале: фон чата, пузырь, альбом, кнопки под постом --- */
.chat {
  --chat: color-mix(in srgb, var(--button) 9%, var(--bg2));
  background-color: var(--chat);
  background-image:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--hint) 14%, transparent) 1.2px, transparent 1.6px),
    radial-gradient(circle at 70% 80%, color-mix(in srgb, var(--hint) 10%, transparent) 1px, transparent 1.4px);
  background-size: 34px 34px, 26px 26px;
  padding: 8px 8px 10px;
}
.datepill {
  display: table; margin: 8px auto; padding: 3px 10px; border-radius: 12px;
  background: color-mix(in srgb, #000 22%, transparent); color: #fff; font-size: 13px; font-weight: 500;
}
.bubble {
  background: var(--bg); border-radius: 14px; overflow: hidden; max-width: 460px; margin: 0 auto 6px;
  box-shadow: 0 1px 1px rgba(0,0,0,.12);
}
.bubble.draft { box-shadow: 0 0 0 2px var(--button), 0 1px 1px rgba(0,0,0,.12); }
.bubble.dim { opacity: .55; }
.bubble-text { padding: 7px 11px 0; font-size: 15.5px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-text .cap { outline: 0; }
.bubble-text .cap[contenteditable]:focus { background: color-mix(in srgb, var(--button) 8%, transparent); border-radius: 4px; }
.bubble-text .src { color: var(--text); }
.bubble-text.edited .src { color: var(--text); }
.bubble-foot { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 2px 10px 6px; font-size: 12px; color: var(--hint); }
.bubble-foot .tag { margin-right: auto; color: var(--accent); font-weight: 500; }
.chat-counter { display: flex; justify-content: space-between; max-width: 460px; margin: 0 auto; padding: 2px 4px 0; font-size: 12.5px; color: var(--hint); }
.chat-counter .num.warn { color: var(--warn); font-weight: 600; }
.chat-counter .num.bad { color: var(--bad); font-weight: 600; }
.chat .problems { max-width: 460px; margin: 4px auto 0; padding: 0 4px; }
.inline-kb { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; max-width: 460px; margin: 0 auto 14px; }
.inline-kb button {
  height: 38px; border-radius: 10px; font-size: 14px; font-weight: 500; color: #fff;
  background: color-mix(in srgb, #000 26%, transparent); backdrop-filter: blur(4px);
}
.inline-kb button.wide { grid-column: span 3; }
.inline-kb button.primary { background: color-mix(in srgb, var(--button) 88%, transparent); }

.mosaic { display: grid; gap: 2px; background: var(--bg); }
.mosaic .mi { position: relative; overflow: hidden; background: #111; cursor: pointer; }
.mosaic .mi img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic.n1 .mi { aspect-ratio: var(--ar, 4/3); max-height: 70vh; }
.mosaic.n1 .mi img { object-fit: contain; }
.mi.spoiler img { filter: blur(22px) brightness(.8); transform: scale(1.15); }
.mi .spoiler-cover { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 600;
  background-image: radial-gradient(rgba(255,255,255,.4) 1px, transparent 1.2px); background-size: 7px 7px; }
.channel-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--sep); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #8a6d4b, #4e3b28); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.channel-head .name { font-weight: 600; }

/* --- Mini App: кнопки под постом, правка, служебные экраны --- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
.quick .btn { height: 56px; flex-direction: column; gap: 2px; font-size: 12.5px; font-weight: 500; background: var(--section); }
.quick .btn span { font-size: 19px; line-height: 1; }
.inline-kb.two { grid-template-columns: 2fr 1fr; }
.inline-kb button:disabled { opacity: .5; }
.mi img { min-height: 120px; }
.bubble-foot .tag.warn { color: var(--warn); }
.viewer .vimg img { touch-action: pinch-zoom; }
.slot .held { color: var(--warn); font-size: 13px; }
.screen { min-height: 80vh; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--hint); }
.screen .btn { margin-top: 16px; }
.loading { opacity: .6; pointer-events: none; }
.scrim.still, .sheet.still { animation: none; }
.spark { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--bg); }
.spark svg { flex: 1; height: 30px; }
.spark polyline { fill: none; stroke: var(--button); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .ok { color: var(--ok); }
.spark .bad { color: var(--bad); }
img.avatar { object-fit: cover; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; max-width: 460px; margin: -2px auto 8px; }
.reacts span { padding: 2px 8px; border-radius: 12px; font-size: 13px; color: #fff; background: color-mix(in srgb, #000 26%, transparent); }
.btn.small { height: 28px; padding: 0 8px; font-size: 13px; text-transform: none; letter-spacing: 0; }
