:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a90);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --red: #e5484d;
  --green: #30a46c;
  --amber: #d9822b;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 12px 8px;
  border-bottom: 1px solid var(--bg2); }
h1 { font-size: 17px; margin: 0 0 8px; }
h3 { margin: 6px 0 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--bg2);
  color: var(--text); font: inherit; font-size: 13px; }
.chip.on { background: var(--btn); color: var(--btn-text); }
input[type=search] { width: 100%; margin-top: 8px; padding: 9px 12px; border: 0; border-radius: 10px;
  background: var(--bg2); color: var(--text); font: inherit; outline: none; }
main { padding: 10px 12px; max-width: 720px; margin: 0 auto; }
.card { background: var(--bg); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.meta { color: var(--hint); font-size: 12px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  color: #fff; margin-right: 6px; }
.tag.deleted { background: var(--red); } .tag.edited { background: var(--amber); }
.tag.media { background: var(--green); }
.txt { white-space: pre-wrap; word-break: break-word; margin-top: 6px; }
.old { border-left: 3px solid var(--red); padding-left: 8px; margin-top: 8px; }
.new { border-left: 3px solid var(--green); padding-left: 8px; margin-top: 8px; }
.lbl { font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; }
.media { margin-top: 8px; }
.media img, .media video { max-width: 100%; max-height: 360px; border-radius: 10px; display: block; }
.media audio { width: 100%; }
.more { display: block; width: 100%; padding: 12px; border: 0; border-radius: var(--radius);
  background: var(--bg); color: var(--link); font: inherit; margin-bottom: 10px; }
.empty { text-align: center; color: var(--hint); padding: 40px 12px; }
.chat { cursor: pointer; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--btn); color: var(--btn-text);
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.msg { max-width: 85%; padding: 8px 10px; border-radius: 14px; margin: 4px 0; background: var(--bg);
  word-break: break-word; }
.msg.mine { margin-left: auto; background: var(--btn); color: var(--btn-text); }
.msg.deleted { outline: 1.5px dashed var(--red); }
.msg .meta { color: inherit; opacity: .7; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cell { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg);
  display: flex; align-items: center; justify-content: center; position: relative; }
.cell img, .cell video { width: 100%; height: 100%; object-fit: cover; }
.cell .ico { font-size: 28px; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 0;
  border-bottom: 1px solid var(--bg2); gap: 12px; }
.switch:last-child { border-bottom: 0; }
.switch input { flex: none; width: 46px; height: 26px; appearance: none; -webkit-appearance: none;
  background: var(--hint); opacity: .5; border-radius: 999px; position: relative; transition: .2s; outline: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked { background: var(--btn); opacity: 1; }
.switch input:checked::after { left: 23px; }
nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg);
  border-top: 1px solid var(--bg2); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav button { flex: 1; border: 0; background: none; padding: 9px 0 8px; color: var(--hint); font: inherit;
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav button span { font-size: 20px; line-height: 1; }
nav button.on { color: var(--btn); }
.back { border: 0; background: none; color: var(--link); font: inherit; padding: 0; margin-bottom: 6px; flex: none; }
.chat-bar { display: flex; align-items: center; gap: 10px; }
.chat-bar .back { margin-bottom: 0; }
.chat-bar-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err { color: var(--red); text-align: center; padding: 30px 12px; }
.btn { display: block; width: 100%; border: 0; border-radius: 10px; padding: 12px; font: inherit;
  background: var(--btn); color: var(--btn-text); margin-top: 8px; }
.btn.danger { background: var(--red); color: #fff; }
.btn.plain { background: var(--bg2); color: var(--text); }
a.btn { text-align: center; text-decoration: none; }
.stat { display: flex; justify-content: space-between; padding: 6px 0; }
.note { color: var(--hint); font-size: 12px; margin: 6px 2px 12px; }
.daysep { text-align: center; font-size: 12px; color: var(--hint); margin: 12px 0 6px; }
.vidwrap { position: relative; width: 100%; height: 100%; }
.vidwrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.playbtn { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.playbtn::after { content: ""; position: absolute; left: 21px; top: 16px;
  border-style: solid; border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #fff; }
.playbtn.off { display: none; }
.cell-label { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; font-size: 10px;
  padding: 4px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.avatar { object-fit: cover; }
