/* SonlyBOT — панель управления. Тёмно-серая «студийная» тема, бирюзовый + розово-фиолетовый акценты. */
:root {
    --bg: #1b1d21;
    --bg-2: #202328;
    --card: #272a30;
    --card-2: #2e3238;
    --line: rgba(255, 255, 255, .07);
    --line-2: rgba(255, 255, 255, .13);
    --text: #e9ebee;
    --hint: #8d939d;
    --teal: #3aa9a3;
    --teal-2: #2d8f8a;
    --violet: #9a78c8;
    --pink: #c97fae;
    --accent: linear-gradient(135deg, #2f9a95 0%, #7d68b8 100%);
    --ring: linear-gradient(135deg, #74c9dc, #dd90bd);
    --danger: #e0707a;
    --ok: #4cb99a;
    --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.center { text-align: center; }
.hint { color: var(--hint); font-size: 13px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .1px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; background: rgba(255,255,255,.08);
       border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }

/* ---------- каркас ---------- */
.shell { max-width: 1040px; margin: 0 auto; padding: 14px 14px 80px; padding-top: max(14px, env(safe-area-inset-top)); }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.brand .ico { width: 40px; height: 40px; border-radius: 13px; flex: none; }
.brand .name { font-size: 18px; font-weight: 700; line-height: 1.1; }
.brand .sub { color: var(--hint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 8px; max-width: 40%; padding: 7px 12px 7px 10px; border-radius: 999px;
        background: var(--card); border: 1px solid var(--line-2); color: var(--text); font-size: 13px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .ic { width: 16px; height: 16px; flex: none; }
.layout { display: grid; gap: 18px; }
.side { display: none; }
@media (min-width: 900px) {
    .shell { padding: 26px 24px 60px; }
    .layout { grid-template-columns: 250px 1fr; align-items: start; }
    .side { display: block; position: sticky; top: 20px; }
    .page-head .back { display: none; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .chat-list { grid-template-columns: 1fr 1fr; }
}

/* ---------- иконки ---------- */
.ic { width: 22px; height: 22px; fill: none; stroke: url(#ig); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico { width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center;
       border: 1.5px solid transparent;
       background: linear-gradient(var(--card-2), var(--card-2)) padding-box, var(--ring) border-box; }
.ico.sm { width: 36px; height: 36px; border-radius: 12px; }
.ico.sm .ic { width: 18px; height: 18px; }
.ico.dim { opacity: .55; }

/* ---------- карточки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title .grow { flex: 1; min-width: 0; }
.card-title .hint { margin-top: 1px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.split { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- сетка модулей ---------- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; color: var(--hint);
                 font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.mod { position: relative; text-align: left; display: flex; flex-direction: column; gap: 12px; min-height: 118px; padding: 14px;
       background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); cursor: pointer;
       transition: transform .12s ease, border-color .12s ease, background .12s ease; }
.mod:hover { border-color: var(--line-2); background: var(--card-2); }
.mod:active { transform: scale(.98); }
.mod .t { font-weight: 650; font-size: 15px; }
.mod .d { color: var(--hint); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.mod .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mod.soon .t, .mod.soon .d { opacity: .75; }
.mod.hid { opacity: .5; }
.pill { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.07); color: var(--hint); white-space: nowrap; }
.pill.on { background: rgba(76,185,154,.15); color: var(--ok); }
.pill.warn { background: rgba(224,112,122,.15); color: var(--danger); }
.pill.soon { background: rgba(154,120,200,.16); color: #b69be0; }
.mod-toggle { position: absolute; top: 12px; right: 12px; }

/* ---------- боковое меню ---------- */
.side .nav { display: flex; flex-direction: column; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.side .nav button { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 12px;
                    background: transparent; border: 0; color: var(--text); font-size: 14px; }
.side .nav button:hover { background: var(--card); }
.side .nav button.active { background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.side .nav .soon-dot { margin-left: auto; font-size: 10.5px; color: #b69be0; }
.side .nav-title { color: var(--hint); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; margin: 14px 10px 6px; }

/* ---------- шапка страницы ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-head .back { width: 38px; height: 38px; padding: 0; border-radius: 12px; display: grid; place-items: center; flex: none; }
.page-head .back .ic { width: 20px; height: 20px; }
.page-head h1 { font-size: 19px; }

/* ---------- элементы форм ---------- */
label.field { display: block; font-size: 13px; color: var(--hint); }
label.field > span { display: block; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=url], input[type=time], textarea, select {
    width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2);
    border-radius: 12px; padding: 11px 13px; font: inherit; transition: border-color .12s, box-shadow .12s; }
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
select { appearance: none; padding-right: 34px;
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238d939d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
         background-repeat: no-repeat; background-position: right 13px center; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(58,169,163,.2); }
input[type=time]::-webkit-calendar-picker-indicator { filter: invert(.7); }
::placeholder { color: #666c76; }

/* переключатели вместо галочек */
input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 24px; margin: 0; border-radius: 999px;
    background: #3a3e45; border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background .15s; }
input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
    background: #c9cdd3; transition: transform .15s, background .15s; }
input[type=checkbox]:checked { background: var(--accent); border-color: transparent; }
input[type=checkbox]:checked::after { transform: translateX(18px); background: #fff; }
input[type=checkbox]:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
label.check { display: flex; gap: 12px; align-items: center; cursor: pointer; justify-content: space-between; flex-direction: row-reverse; }
label.check > span { flex: 1; }

button { font: inherit; cursor: pointer; border-radius: 12px; padding: 10px 14px; background: var(--card-2); color: var(--text);
         border: 1px solid var(--line-2); transition: background .12s, border-color .12s, opacity .12s; }
button:hover { background: #363a41; }
button.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 650; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.small { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
button.block { width: 100%; padding: 13px; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 4px 10px; font-size: 12.5px; border-radius: 999px; font-family: ui-monospace, Consolas, monospace; }
.error { color: var(--danger); font-size: 13px; }

/* ---------- список чатов ---------- */
.chat-list { display: grid; gap: 10px; }
.chat-item { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; padding: 13px 14px; border-radius: var(--radius);
             background: var(--card); border: 1px solid var(--line); }
.chat-item:hover { border-color: var(--line-2); background: var(--card-2); }
.chat-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .info { flex: 1; min-width: 0; }
.avatar { width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 17px;
          color: #fff; background: var(--accent); }

/* ---------- предпросмотр ---------- */
.preview { background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 12px; padding: 11px 13px;
           white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.preview a { color: #7cc4e8; }
.preview code, .preview pre { background: rgba(255,255,255,.1); }
.preview .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preview .btns span { flex: 1; text-align: center; background: rgba(255,255,255,.1); border-radius: 9px; padding: 6px; }

/* ---------- триггеры, команды, действия ---------- */
.trigger { display: flex; gap: 12px; align-items: center; padding: 13px 14px; }
.trigger .info { flex: 1; min-width: 0; }
.trigger .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trigger.off .name { opacity: .5; }
.cmd { padding: 12px 0; border-top: 1px solid var(--line); }
.cmd:first-of-type { border-top: 0; padding-top: 0; }
.cmd .head { font-weight: 600; margin-bottom: 3px; }
.action { border: 1px solid var(--line-2); border-radius: 13px; padding: 10px; margin-bottom: 8px; background: var(--bg-2); }
.empty { text-align: center; padding: 26px 16px; }
.empty .ico { margin: 0 auto 12px; }

/* ---------- всплывающая карточка редактирования ---------- */
.sheet { position: fixed; inset: 0; background: rgba(8,9,11,.7); backdrop-filter: blur(3px); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet > .panel { background: var(--bg); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px;
                  max-width: 560px; border: 1px solid var(--line-2); border-bottom: 0; }
@media (min-width: 900px) {
    .sheet { align-items: center; }
    .sheet > .panel { border-radius: 22px; border-bottom: 1px solid var(--line-2); max-height: 88vh; }
}

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #14161a; color: #fff; border: 1px solid var(--line-2);
         padding: 11px 18px; border-radius: 14px; font-size: 14px; max-width: 90%; z-index: 20; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.err { background: #4a1d24; border-color: rgba(224,112,122,.4); }
.footer { text-align: center; color: #5f6570; font-size: 12px; margin-top: 24px; }

@media (min-width: 900px) { .page-head .back { display: none; } }

/* ---------- каталог модулей ---------- */
.cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cats button.on { background: var(--accent); border-color: transparent; color: #fff; }
.catalog { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .catalog { grid-template-columns: 1fr 1fr; } }
.mcard { display: flex; flex-direction: column; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.mcard-head { display: flex; align-items: center; gap: 11px; }
.mcard-head h3 { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; }
.mcard-desc { margin: 0; color: var(--hint); font-size: 13.5px; flex: 1; }
.tag { align-self: flex-start; font-size: 12px; padding: 3px 10px; border-radius: 8px; background: rgba(58,169,163,.16); color: #6fd0c8; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kv > span:last-child, .kv > code { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- теги категорий ---------- */
.tag.t-green { background: rgba(86,170,120,.2); color: #7fd3a0; }
.tag.t-tan { background: rgba(200,160,110,.2); color: #e0b987; }
.tag.t-violet { background: rgba(154,120,200,.22); color: #bda3e6; }
.tag.t-pink { background: rgba(212,120,140,.2); color: #eb9aad; }
.tag.t-teal { background: rgba(58,169,163,.2); color: #6fd0c8; }
.mcard.soon .mcard-desc, .mcard.soon h3 { opacity: .8; }
.mcard.add-module { align-items: center; justify-content: center; flex-direction: row; gap: 8px; min-height: 120px; color: var(--hint);
                    border: 1px dashed var(--line-2); background: transparent; }
.mcard.add-module:hover { color: var(--text); border-color: var(--teal); }
.mcard.add-module .ic { width: 20px; height: 20px; }
.mcard.add-module .pill { margin-left: 4px; }

/* ---------- редактор текста ---------- */
.rt-box { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.rt-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(58,169,163,.2); }
.rt-bar { display: flex; align-items: center; gap: 4px; padding: 7px 8px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.rt-bar::-webkit-scrollbar { display: none; }
.rt-btn { flex: none; min-width: 34px; height: 32px; padding: 0 8px; border-radius: 9px; background: transparent; border: 1px solid transparent; color: var(--text); font-size: 14px; }
.rt-btn:hover { background: var(--card-2); border-color: var(--line-2); }
.rt-btn.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.rt-btn.wide { color: #8fd0e0; font-size: 13px; padding: 0 10px; }
.rt-sep { flex: none; width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
.rt-box textarea { border: 0; border-radius: 0; background: transparent; box-shadow: none !important; min-height: 130px; }
.rt-box textarea:focus { box-shadow: none; }
.rt-foot { display: flex; justify-content: flex-end; padding: 4px 12px 8px; }
.rt-count { font-size: 12px; color: var(--hint); }
.rt-count.over { color: var(--danger); font-weight: 600; }
.rt-pop { padding: 10px; border-bottom: 1px solid var(--line); background: var(--card); }
.rt-ph { display: flex; width: 100%; align-items: center; gap: 12px; text-align: left; margin-bottom: 4px; background: transparent; border: 0; padding: 7px 8px; }
.rt-ph:hover { background: var(--card-2); }
.rt-emoji { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.rt-emoji button { font-size: 20px; padding: 4px; background: transparent; border: 0; }
.rt-emoji button:hover { background: var(--card-2); }

/* ---------- кнопки под сообщением ---------- */
.btnrow { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 13px; padding: 10px; display: grid; gap: 8px; }
.btn-target .kind { flex: 0 0 44%; }
.add-btn { align-self: center; justify-self: center; display: block; margin: 0 auto; border-radius: 999px; padding: 9px 20px;
           background: rgba(58,169,163,.14); border: 1px solid rgba(58,169,163,.45); color: #7fd6cf; font-weight: 600; }
.add-btn:hover { background: rgba(58,169,163,.24); }

/* ---------- фото ---------- */
.photo { background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 13px; padding: 10px; }
.thumb { width: 56px; height: 56px; border-radius: 11px; object-fit: cover; flex: none; border: 1px solid var(--line-2); }
.thumb.ph { display: grid; place-items: center; background: var(--card); font-size: 22px; }
.pv-img { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px 12px 0 0; margin-bottom: -1px; border: 1px solid var(--line-2); border-bottom: 0; }
.pv-img:not(.hidden) + .preview { border-top-left-radius: 0; border-top-right-radius: 0; border-style: solid; border-color: var(--line-2); }

/* ---------- тарифы ---------- */
.pill.lock { background: rgba(221,144,189,.14); color: #e6a6cb; }
.mcard.locked h3, .mcard.locked .mcard-desc { opacity: .8; }
.chat-item.dim { opacity: .6; }
.chat-list > * { min-width: 0; }  /* длинная подпись сжимается, а не выталкивает кнопку за край */
.chat-list { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .chat-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.chat-item > button { flex: none; }
.chat-item.hl { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(58,169,163,.18); }
.chat-item .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-strip { margin-bottom: 16px; background: linear-gradient(var(--card), var(--card)) padding-box, var(--ring) border-box;
              border: 1px solid transparent; }
.plans { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 12px; }
@media (min-width: 700px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan { display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.plan.current { background: linear-gradient(var(--card), var(--card)) padding-box, var(--ring) border-box; border-color: transparent; }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-head h3 { font-size: 16px; }
.price { font-size: 22px; font-weight: 700; display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.price .hint { font-weight: 400; }
.price .old { font-size: 15px; font-weight: 500; color: var(--hint); text-decoration-thickness: 1.5px; }
.plan .stars { margin-top: -6px; }
.plan .stars s { opacity: .7; }
.pill.sale { background: rgba(221,144,189,.18); color: #f0a9d1; font-weight: 650; }
.plan-list { margin: 0; padding-left: 18px; color: var(--hint); font-size: 13.5px; flex: 1; }
.plan-list li + li { margin-top: 4px; }

/* ---------- журнал ---------- */
.card.log { padding: 12px 14px; margin-bottom: 8px; }
.card.log > * + * { margin-top: 3px; }

/* ---------- переключатель языка ---------- */
.lang-switch { display: inline-flex; flex: none; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; background: var(--card); }
.lang-switch button { border: 0; border-radius: 0; background: transparent; padding: 6px 10px; font-size: 12px; font-weight: 650; color: var(--hint); }
.lang-switch button.on { background: var(--accent); color: #fff; }
