/* 0.10 staging: only visible controls when feature flag is enabled. */
body{isolation:isolate}
body[data-pattern]:not([data-pattern="none"])::before{
 content:"";position:fixed;inset:0;z-index:-1;pointer-events:none;
 background-position:5px 8px;background-repeat:repeat;
 background-size:120px 120px;opacity:.09
}
body[data-pattern="lotus"]::before{background-image:url("patterns/lotus.svg")}
body[data-pattern="wheel"]::before{background-image:url("patterns/wheel.svg")}
:root[data-theme="dark"] body[data-pattern]:not([data-pattern="none"])::before{opacity:.065;filter:invert(1)}
.feature-toolbar{display:flex;flex-wrap:wrap;gap:6px;margin:10px 2px 6px}
.feature-toolbar button,.feature-chip,.feature-chipbtn{
 font:12px/1.35 inherit;border:1px solid var(--line);border-radius:12px;
 background:var(--card);color:var(--text);padding:5px 9px;
 cursor:pointer;min-height:30px
}
.feature-toolbar .fimportant{border-color:var(--accent);color:var(--accent)}
.feature-toolbar button:focus-visible,.feature-actions button:focus-visible{
 outline:2px solid var(--accent);outline-offset:2px
}
.feature-actions{display:flex;gap:5px;flex-wrap:wrap;margin-top:7px}
.feature-actions button{border:1px solid var(--line);border-radius:7px;
 background:var(--card);font:inherit;font-size:12px;padding:3px 7px;color:var(--muted)}
.feature-actions button.own{border-color:var(--accent);color:var(--accent)}
.feature-actions .femoji{font-size:13px;padding:3px 6px}
.feature-banner{background:var(--accent-2);border-radius:10px;padding:8px 11px;
 margin:7px 2px;display:flex;align-items:center;justify-content:space-between;
 font-size:13px;color:var(--text);gap:8px}
.feature-panel{border:1px solid var(--line);border-radius:12px;
 padding:12px;background:var(--card);margin:8px 0;box-shadow:var(--shadow)}
.feature-panel input,.feature-panel select,.feature-panel textarea{max-width:100%;min-height:34px;
 border:1px solid var(--line);background:var(--bg);color:var(--text);
 border-radius:8px;padding:6px;font:inherit}
.feature-panel button,.feature-modal button{padding:5px 8px;margin:4px 3px;
 border:1px solid var(--line);border-radius:8px;background:var(--accent-2);
 color:var(--text)}
.feature-panel .flist{display:grid;gap:5px}
.feature-panel .flist button{text-align:left;white-space:normal;overflow-wrap:anywhere}
.feature-panel mark{background:#ffe8a2;color:#241900}
.feature-modal{position:fixed;inset:0;z-index:30;background:rgba(0,0,0,.65);
 display:grid;place-items:center;padding:18px}
.feature-modal .fcontent{background:var(--card);padding:18px;border-radius:14px;
 max-width:430px;width:100%;max-height:90vh;overflow-y:auto;color:var(--text)}
.feature-modal img{width:min(200px,90%);max-height:240px;object-fit:contain;border-radius:50%}
.feature-modal .fheader{display:flex;justify-content:space-between;align-items:center;gap:10px}
.feature-gallery{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;margin-top:12px}
.feature-gallery button{aspect-ratio:1;background:var(--chip);border-radius:9px;overflow:hidden;min-width:0}
.feature-gallery img,.feature-gallery video{width:100%;height:100%;object-fit:cover}
.feature-edit-box{width:100%;min-height:70px;max-height:300px}
.feature-quote{font-size:12px;border-left:2px solid var(--accent);padding:3px 8px;
 margin:3px 0;color:var(--muted);max-width:95%;overflow-wrap:anywhere;text-align:left}
.feature-unread{display:block;margin:9px 0;background:var(--accent-2);
 color:var(--accent);padding:7px 12px;border-radius:10px;text-align:center;font-size:13px}
.feature-newline{font-size:11px;color:var(--muted);margin:4px}
.feature-avatar-image{width:100%;height:100%;border-radius:50%;object-fit:cover}
.feature-suggest{position:absolute;bottom:100%;left:0;right:0;background:var(--card);
 padding:5px;max-height:170px;overflow-y:auto;z-index:6;
 border:1px solid var(--line);box-shadow:var(--shadow);border-radius:12px}
.feature-suggest button{padding:6px 9px;width:100%;display:block;text-align:left}
.feature-subtle{font-size:12px;color:var(--muted)}
.feature-qa{font-size:11px;color:var(--accent);padding:3px 6px}
.feature-load-older{display:block;margin:6px auto;padding:8px 13px!important}
.feature-gallery-head{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.feature-send-status{font-size:12px;color:var(--muted);margin-top:3px}
@media(max-width:360px){
 .feature-toolbar{gap:4px}
 .feature-toolbar button{font-size:11px;padding:5px 7px}
 .c.reply{margin-left:24px}
 .feature-actions button{padding:3px 5px}
 .wrap{padding:8px 8px 0}
 .feature-gallery{grid-template-columns:repeat(2,minmax(0,1fr))}
}

.feature-reactions{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
.feature-rx-chips{display:contents}
.feature-rx-picker{display:flex;flex-wrap:wrap;gap:4px;padding:3px 5px;border:1px solid var(--line);border-radius:14px;background:var(--card)}
.feature-rx-picker[hidden]{display:none}
.feature-reactions .femoji.own{border-color:var(--accent)}
.feature-reactions[hidden]{display:none}
.feature-rx-sheet{position:fixed;inset:0;z-index:50;background:rgba(0,0,0,.4);display:flex;align-items:flex-end;justify-content:center}
.feature-rx-card{width:100%;max-width:480px;max-height:70vh;overflow:auto;background:var(--card);color:var(--text);border-radius:16px 16px 0 0;padding:14px 16px 18px}
.feature-rx-title{font-weight:600;margin-bottom:8px}
.feature-rx-line{display:flex;gap:10px;align-items:baseline;margin:6px 0}
.feature-rx-e{font-size:18px}
.feature-rx-n{flex:1;word-break:break-word}
.feature-rx-card .femoji{margin-top:10px}

/* ===== chat_ui: внешний вид как в чатах MAX (опциональный флаг) ===== */
html.chat-ui{
  --bg:#cfe3f5; --bg-top:#9cc4ee; --bg-bot:#d6e7f6; --card:#ffffff; --text:#101820; --muted:#6c7b8b;
  --line:rgba(16,24,32,.09); --accent:#1a8cc6; --accent-2:#e3f1fb; --chip:#e8eff6; --danger:#d93a3a;
  --pill:#1b8dc0; --pill-own:#0b6a99; --mine:#d7eeff; --shadow:0 1px 2px rgba(0,0,0,.14);
}
@media (prefers-color-scheme: dark){
  html.chat-ui:not([data-theme="light"]){
    --bg:#0e1621; --bg-top:#101c2b; --bg-bot:#0b121b; --card:#182533; --text:#e8eef4; --muted:#8c9cac;
    --line:rgba(255,255,255,.09); --accent:#5eb5f7; --accent-2:#1f3447; --chip:#22303f; --danger:#ff7b7b;
    --pill:#2b6f9e; --pill-own:#3f93cf; --mine:#2b5278;
  }
}
html.chat-ui[data-theme="dark"]{
  --bg:#0e1621; --bg-top:#101c2b; --bg-bot:#0b121b; --card:#182533; --text:#e8eef4; --muted:#8c9cac;
  --line:rgba(255,255,255,.09); --accent:#5eb5f7; --accent-2:#1f3447; --chip:#22303f; --danger:#ff7b7b;
  --pill:#2b6f9e; --pill-own:#3f93cf; --mine:#2b5278;
}
html.chat-ui body{background:linear-gradient(180deg,var(--bg-top),var(--bg-bot)) fixed;min-height:100vh}
html.chat-ui .post{border:0;border-radius:18px;box-shadow:var(--shadow)}
html.chat-ui .count{display:table;margin:14px auto 8px;padding:3px 14px;border-radius:14px;
  background:rgba(255,255,255,.55);color:var(--text);font-size:13px;font-weight:500;letter-spacing:0;text-transform:none}
html.chat-ui[data-theme="dark"] .count{background:rgba(255,255,255,.12)}
html.chat-ui .c{padding:2px 8px;border:0;align-items:flex-end;gap:8px}
html.chat-ui .c.reply{margin-left:42px}
@media (max-width:380px){html.chat-ui .c.reply{margin-left:30px}}
html.chat-ui .c.mine{flex-direction:row-reverse}
html.chat-ui .av{flex:0 0 38px;height:38px;font-size:15px;overflow:hidden}
html.chat-ui .av img{width:100%;height:100%;object-fit:cover;display:block}
html.chat-ui .c.cont .av{visibility:hidden}
html.chat-ui .cb{flex:0 1 auto;max-width:min(86%,520px);min-width:84px;background:var(--card);
  border-radius:18px 18px 18px 6px;padding:7px 12px 6px;box-shadow:var(--shadow);
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
html.chat-ui .c.mine .cb{background:var(--mine);border-radius:18px 18px 6px 18px}
html.chat-ui .meta{gap:6px}
html.chat-ui .meta .name{font-size:14px;font-weight:600}
html.chat-ui .meta .time,html.chat-ui .meta .to,html.chat-ui .meta .feature-subtle{display:none}
html.chat-ui .c.mine .meta .name{display:none}
html.chat-ui .txt{font-size:16px;line-height:1.38;margin-top:1px}
html.chat-ui .txt a{color:var(--accent)}
html.chat-ui .acts,html.chat-ui .feature-actions:not(.feature-reactions){display:none}
html.chat-ui .cfoot{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;margin-top:4px}
html.chat-ui .crx{display:flex;flex-wrap:wrap;gap:5px;min-width:0}
html.chat-ui .ctime{margin-left:auto;font-size:12px;color:var(--muted);white-space:nowrap;padding-bottom:2px}
html.chat-ui .crx .femoji{background:var(--pill);color:#fff;border:0;border-radius:15px;padding:3px 11px;
  font-size:14px;font-weight:600;min-height:28px;line-height:1.2}
html.chat-ui .crx .femoji.own{background:var(--pill-own);box-shadow:inset 0 0 0 2px rgba(255,255,255,.75)}
html.chat-ui .feature-quote{display:block;width:100%;text-align:left;border:0;border-left:3px solid var(--accent);
  background:var(--accent-2);border-radius:6px;padding:4px 8px;margin:3px 0 4px;font-size:13px;color:var(--text);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:0}
html.chat-ui .feature-toolbar{justify-content:center;margin:6px 8px 10px}
html.chat-ui .feature-toolbar button,html.chat-ui .feature-chip,html.chat-ui .feature-chipbtn{
  border:0;background:rgba(255,255,255,.88);color:var(--text);border-radius:16px;box-shadow:var(--shadow)}
html.chat-ui[data-theme="dark"] .feature-toolbar button{background:rgba(255,255,255,.14)}
html.chat-ui .composer{background:linear-gradient(transparent,var(--bg-bot) 40%);border-top:0}
html.chat-ui textarea{background:var(--card);border:0;border-radius:22px;box-shadow:var(--shadow);padding:10px 16px}
html.chat-ui .attach{background:var(--card);box-shadow:var(--shadow);color:var(--muted)}
html.chat-ui .send{background:var(--accent)}
html.chat-ui .replyto{background:var(--card);border-radius:14px;box-shadow:var(--shadow)}
/* меню по долгому нажатию */
.cmenu-ov{position:fixed;inset:0;z-index:60;background:rgba(10,20,35,.38);
  -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);overflow:auto;
  display:flex;justify-content:center;align-items:center;padding:16px}
.cmenu-col{display:flex;flex-direction:column;gap:10px;width:min(100%,440px);margin:auto}
.cmenu-pill{display:flex;justify-content:space-between;background:var(--card);border-radius:30px;
  padding:5px 8px;box-shadow:0 6px 24px rgba(0,0,0,.22)}
.cmenu-e{font-size:25px;line-height:1;padding:7px;border-radius:50%;min-height:0;transition:transform .12s}
.cmenu-e.own{background:var(--accent-2)}
.cmenu-e:active{transform:scale(1.25)}
.cmenu-bub{display:flex;pointer-events:none}
.cmenu-bub.mine{justify-content:flex-end}
.cmenu-bub .cb{max-width:100%;margin:0}
.cmenu-card{background:var(--card);border-radius:16px;overflow:hidden;box-shadow:0 6px 24px rgba(0,0,0,.22);
  width:min(100%,290px);align-self:flex-start}
.cmenu-bub.mine+.cmenu-card{align-self:flex-end}
.cmenu-item{display:flex;align-items:center;gap:14px;width:100%;padding:13px 16px;text-align:left;
  font-size:16px;color:var(--text);min-height:48px}
.cmenu-item:active{background:var(--accent-2)}
.cmenu-item.danger{color:var(--danger)}
.cmenu-ic{display:inline-flex;width:24px;justify-content:center}
.cmenu-sep{height:6px;background:var(--line)}
html.chat-ui .count button{float:none!important;margin-left:10px}
.cmenu-bub.mine .meta .name{display:none}
.cmenu-bub .cfoot{margin-top:4px}
html.chat-ui .notify{display:none}
html.chat-ui .feature-toolbar.icons{gap:10px}
html.chat-ui .feature-toolbar.icons .ficon{width:42px;height:42px;min-height:0;padding:0;border-radius:50%;
  display:grid;place-items:center;background:rgba(255,255,255,.88);color:var(--text);box-shadow:var(--shadow)}
html.chat-ui .feature-toolbar.icons .ficon .cmenu-ic{width:auto}
html.chat-ui .feature-toolbar.icons .ficon.on{color:var(--accent)}
html.chat-ui[data-theme="dark"] .feature-toolbar.icons .ficon{background:rgba(255,255,255,.14)}
.fab-down{position:fixed;right:14px;bottom:calc(86px + env(safe-area-inset-bottom));z-index:6;width:44px;height:44px;
  border-radius:50%;background:var(--card);color:var(--text);box-shadow:0 2px 10px rgba(0,0,0,.25);
  display:none;place-items:center}
.fab-down.on{display:grid}
.fab-down .cmenu-ic{width:auto}
.fab-badge{position:absolute;top:-6px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:10px;
  background:var(--accent);color:#fff;font-size:12px;font-weight:600;line-height:20px;text-align:center}
.fab-badge[hidden]{display:none}
html.chat-ui .cb .grid{width:min(76vw,420px);max-width:none}
html.chat-ui .cb .grid.n1{width:min(72vw,320px)}
html.chat-ui .cb .grid.n2{width:min(76vw,360px)}
html.chat-ui .cb .grid .tile{min-width:0}
.fab-down.fab-up{bottom:calc(140px + env(safe-area-inset-bottom))}

html.chat-ui #featurePanel{position:fixed;left:10px;right:10px;top:calc(10px + env(safe-area-inset-top));z-index:20;
  max-height:72vh;overflow:auto;background:var(--card);color:var(--text);border-radius:16px;
  box-shadow:0 10px 40px rgba(0,0,0,.35);padding:12px}
html.chat-ui #featurePanel input{width:100%;box-sizing:border-box;font-size:16px;border-radius:10px}
