.settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.settings-heading h2 {
  margin: 4px 0 7px;
}
.settings-heading .card-sub {
  margin-bottom: 0;
}
.settings-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid #ffffff18;
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff10, #ffffff05);
  color: #d8ceff;
  box-shadow: inset 0 1px 0 #ffffff12;
}
.settings-icon .line-icon {
  width: 21px;
  height: 21px;
}
.control-list {
  display: grid;
  gap: 9px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 13px 14px 13px 16px;
  border: 1px solid #ffffff10;
  border-radius: 13px;
  background: #0b0a12b8;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.switch-row:hover {
  border-color: #ffffff22;
  background: #11101a;
  transform: translateY(-1px);
}
.switch-row span {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.switch-row strong {
  color: #f4f2fa;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}
.switch-row small {
  color: #9690a1;
  font-size: 11.5px;
  line-height: 1.45;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-row i {
  position: relative;
  flex: 0 0 auto;
  width: 43px;
  height: 24px;
  border: 1px solid #ffffff14;
  border-radius: 999px;
  background: #312d3b;
  box-shadow: inset 0 1px 3px #0008;
  transition: background .18s ease, border-color .18s ease;
}
.switch-row i::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #c9c2d6;
  box-shadow: 0 2px 8px #0007;
  transition: transform .18s ease, background .18s ease;
}
.switch-row input:checked + i {
  border-color: #6ee7bf55;
  background: linear-gradient(135deg, #7c5cff, #27d49c);
}
.switch-row input:checked + i::after {
  transform: translateX(19px);
  background: #fff;
}
.switch-row input:focus-visible + i {
  box-shadow: var(--ring), inset 0 1px 3px #0008;
}
.settings-split {
  display: grid;
  grid-template-columns: minmax(180px, .62fr) minmax(260px, 1fr);
  gap: 14px;
  margin-top: 16px;
}
.chat-settings-split {
  grid-template-columns: minmax(180px, .62fr) minmax(260px, 1fr);
}
.chat-bots-block {
  grid-column: 1 / -1;
}
.setting-block {
  min-width: 0;
}
.select {
  width: 100%;
  min-height: 44px;
  appearance: none;
  background: #0b0a12 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239b94a8' d='m2 4 4 4 4-4z'/%3E%3C/svg%3E") no-repeat right 13px center;
  border: 1px solid #ffffff14;
  color: #ebe8f2;
  border-radius: 12px;
  padding: 11px 36px 11px 13px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.bot-adder {
  display: flex;
  gap: 8px;
}
.bot-adder .input {
  min-height: 44px;
}
.bot-adder button {
  flex: 0 0 44px;
  min-height: 44px;
  border: 1px solid #7c5cff66;
  border-radius: 12px;
  background: linear-gradient(135deg, #2a2140, #15131f);
  color: #d7ccff;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.bot-adder button:hover {
  border-color: #9d86ff;
  background: #332758;
  color: #fff;
  transform: translateY(-1px);
}
.bot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 28px;
  margin-top: 11px;
}
.bot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 6px 6px 10px;
  border: 1px solid #ffffff12;
  border-radius: 999px;
  background: #ffffff08;
  color: #d3cedd;
  font-size: 11px;
  font-weight: 700;
}
.bot-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bot-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff10;
  color: #a59faf;
  cursor: pointer;
}
.bot-chip button:hover {
  background: #4a2132;
  color: #ffb1cc;
}
.empty-bots {
  color: #797382;
  font-size: 11px;
  padding: 6px 1px;
}

.textarea {
  min-height: 170px;
  line-height: 1.5;
  resize: vertical;
}

.field-hint {
  display: block;
  margin-top: 7px;
  color: #827b8e;
  font-size: 11.5px;
  line-height: 1.45;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #a89cff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.text-button:hover {
  color: #fff;
}

.text-button:disabled {
  opacity: .35;
  cursor: default;
}

.telegram-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 18px;
  align-items: start;
}

.telegram-card {
  display: grid;
  gap: 18px;
  background:
    linear-gradient(180deg, #181520, #100f18 62%, #0b0d12),
    #111018;
}

.telegram-state,
.telegram-error {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #ffffff10;
  border-radius: 8px;
  background: #0b0a12b8;
  color: #aaa3b5;
  font-size: 12px;
  font-weight: 750;
}

.telegram-state i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8b8496;
}

.telegram-state.is-ok {
  border-color: #45d7a744;
  color: #86e8c8;
}

.telegram-state.is-ok i {
  background: #38d6a3;
  box-shadow: 0 0 12px #38d6a3;
}

.telegram-state.is-warn {
  border-color: #f2b84b44;
  color: #f0c77b;
}

.telegram-state.is-warn i {
  background: #ffbd5a;
}

.telegram-error {
  border-color: #ff6b9b35;
  color: #ffadc9;
  background: #24111b;
}

.telegram-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 240px);
  gap: 12px;
  align-items: start;
}

.telegram-event-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.telegram-event-card {
  position: relative;
  min-height: 92px;
  padding: 13px 42px 13px 13px;
  border: 1px solid #282538;
  border-radius: 8px;
  background: #0b0a12;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .16s, background .16s, transform .16s;
}

.telegram-event-card:hover {
  border-color: color-mix(in srgb, var(--event-color, #229ed9) 52%, #282538);
  background: #11101a;
  transform: translateY(-1px);
}

.telegram-event-card.is-start { --event-color: #38d6a3; }
.telegram-event-card.is-end { --event-color: #8b5cff; }

.telegram-event-card input {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 17px;
  height: 17px;
  accent-color: var(--event-color, #229ed9);
}

.event-mark {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--event-color, #229ed9) 42%, transparent);
  border-radius: 7px;
  color: color-mix(in srgb, var(--event-color, #229ed9) 82%, #fff);
  background: color-mix(in srgb, var(--event-color, #229ed9) 14%, transparent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
}

.telegram-event-card strong,
.telegram-event-card small {
  position: relative;
  z-index: 1;
  display: block;
}

.telegram-event-card strong {
  margin-top: 10px;
  color: #f7f2ff;
  font-size: 14px;
  line-height: 1.15;
}

.telegram-event-card small {
  margin-top: 5px;
  color: #8d8599;
  font-size: 11px;
  line-height: 1.35;
}

.telegram-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.telegram-template-block {
  min-width: 0;
}

.telegram-stats-card {
  display: grid;
  grid-template-columns: minmax(220px, .42fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid #3a3550;
  border-radius: 10px;
  background: linear-gradient(145deg, #12101a, #0b0a12);
}

.telegram-stats-card .field-label {
  color: #ece7f8;
  margin-bottom: 0;
}

.telegram-stats-card p {
  margin: 8px 0 0;
  color: #c8bfd8;
  font-size: 12.5px;
  line-height: 1.55;
}

.telegram-stats-card code {
  color: #e8dcff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  background: #8b5cff22;
  border: 1px solid #8b5cff44;
}

.tg-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tg-stat-toggle {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #3a3550;
  border-radius: 9px;
  background: #11101a;
  color: #e8e2f4;
  font-size: 11.5px;
  font-weight: 750;
  line-height: 1.25;
  cursor: pointer;
}

.tg-stat-toggle > span:last-child {
  white-space: normal;
}

.tg-stat-toggle input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  accent-color: #8b5cff;
}

.tg-stat-toggle:has(input:checked) {
  border-color: #8b5cff66;
  background: #8b5cff14;
  color: #f6f0ff;
}

.tg-stat-ico {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex: 0 0 18px;
  color: #9d86ff;
}

.tg-stat-ico .line-icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

.tg-stat-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-link-grid {
  display: grid;
  grid-template-columns: minmax(190px, 320px);
  gap: 14px;
}

.telegram-channel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.tg-accent-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 7px;
  border: 1px solid #ffffff14;
  border-radius: 12px;
  background: #0b0a12;
  cursor: pointer;
}

.tg-accent-row input {
  width: 48px;
  height: 32px;
  flex: 0 0 48px;
  padding: 2px;
  border: 1px solid #ffffff18;
  border-radius: 9px;
  background: #08070e;
  cursor: pointer;
}

.tg-accent-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tg-accent-row strong {
  color: #f5f2fb;
  font-size: 12px;
  line-height: 1.1;
}

.tg-accent-row small {
  color: #8d8599;
  font-size: 10.5px;
  line-height: 1.2;
}

.template-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.template-vars button {
  min-height: 28px;
  border: 1px solid #ffffff12;
  border-radius: 999px;
  background: #ffffff07;
  color: #cfc8dc;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.template-vars .format-button {
  min-width: 31px;
  border-color: #8b5cff55;
  background: #8b5cff1a;
  color: #fff;
  font-family: Georgia, serif;
  font-size: 13px;
}

.tg-buttons {
  display: grid;
  gap: 9px;
}

.tg-button-row {
  display: grid;
  grid-template-columns: minmax(110px, .72fr) minmax(160px, 1fr) 128px 42px;
  gap: 8px;
  align-items: center;
}

.tg-remove-button {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 20px;
}

.telegram-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.telegram-preview {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  border: 1px solid #282538;
  border-radius: 8px;
  background: #111018;
  box-shadow: 0 16px 40px #00000045;
  overflow: hidden;
}

.telegram-preview-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border-bottom: 1px solid #282538;
  color: #a9a2b4;
  font-size: 12px;
}

.telegram-preview-top span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tg-accent);
  box-shadow: 0 0 14px var(--tg-accent);
}

.telegram-chat {
  display: grid;
  gap: 12px;
  padding: 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tg-accent) 8%, #111827), #0f1320 46%),
    #0f1320;
}

.telegram-post {
  margin: 0;
  padding: 12px;
  border: 1px solid #2a3449;
  border-radius: 8px;
  background: #172033;
  color: #eef3fb;
  box-shadow: inset 0 1px 0 #ffffff0b;
}

.telegram-post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}

.telegram-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tg-accent), #4ca5ff);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.telegram-avatar.is-vk {
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.telegram-avatar.is-vk img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.telegram-post-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.telegram-post-head strong {
  color: #f9f6ff;
  font-size: 12.5px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-post-head small {
  color: #8ea0bb;
  font-size: 10.5px;
}

.telegram-post-text {
  margin: 0;
  color: #f6f8fc;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.telegram-post-text strong {
  color: #fff;
  font-weight: 900;
}

.telegram-post-text a {
  color: #89b8ff;
  font-weight: 800;
  text-decoration: none;
}

.telegram-link-preview {
  display: grid;
  gap: 9px;
  margin-top: 11px;
  padding-left: 10px;
  border-left: 3px solid var(--tg-accent);
}

.telegram-link-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.telegram-link-meta strong {
  color: #89cfff;
  font-size: 12px;
  line-height: 1.15;
}

.telegram-link-meta span,
.telegram-link-meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-link-meta span {
  color: #f8f6ff;
  font-size: 12.5px;
  font-weight: 850;
}

.telegram-link-meta small {
  color: #d7dcec;
  font-size: 11.5px;
}

.telegram-preview-buttons {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.tg-preview-button {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  box-shadow: inset 0 1px 0 #ffffff24;
}

.tg-preview-button.is-primary { background: linear-gradient(135deg, var(--tg-accent), #2aabee); }
.tg-preview-button.is-success { background: linear-gradient(135deg, #27d49c, #179c73); }
.tg-preview-button.is-danger { background: linear-gradient(135deg, #d95050, #a83b2f); }

.compose-layout {
  align-items: start;
}

.compose-editor {
  display: grid;
  gap: 14px;
}

.compose-dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 160px;
  padding: 18px;
  border: 1px dashed #3a3550;
  border-radius: 10px;
  background: linear-gradient(180deg, #17141f, #121018);
  color: #a9a2b4;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}

.compose-dropzone.is-dragover,
.compose-dropzone.is-uploading {
  border-color: #2aabee;
  background: #171d28;
}

.compose-dropzone.has-image {
  padding: 0;
  overflow: hidden;
  border-style: solid;
}

.compose-dropzone.has-image img,
.telegram-compose-image img {
  display: block;
  width: 100%;
  max-height: none;
  height: auto;
  object-fit: contain;
  background: #0b0a10;
}

.telegram-compose-image {
  margin: 0 0 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #0b0a10;
}

.compose-dropzone-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #0f0d16;
}

.compose-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compose-send-card {
  padding: 16px 18px;
}

.compose-send-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.compose-send-copy {
  min-width: min(100%, 220px);
  flex: 1 1 220px;
}

.compose-send-copy strong {
  display: block;
  margin-bottom: 4px;
  color: #f2eef8;
  font-size: 14px;
  font-weight: 750;
}

.compose-send-copy p {
  margin: 0;
  color: #9b94a8;
  font-size: 13px;
  line-height: 1.4;
}

.compose-send-button {
  flex: 0 0 auto;
  min-width: 188px;
  background: linear-gradient(135deg, #2aabee, #229ed9) !important;
  border-color: #1f8fc4 !important;
  box-shadow: 0 8px 20px #229ed940;
}

.compose-send-button:hover:not(:disabled) {
  filter: brightness(1.06);
}

.compose-send-button:disabled {
  opacity: .45;
  box-shadow: none;
}

.compose-history-card .compose-history-list {
  margin-top: 4px;
}

.compose-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.compose-history-item {
  display: block;
  padding: 0;
  border: 1px solid #2c273a;
  border-radius: 12px;
  background: linear-gradient(180deg, #17141f, #121018);
  overflow: hidden;
}

.compose-history-item.is-err {
  border-color: #5a3038;
  background: linear-gradient(180deg, #1c1418, #141018);
}

.compose-history-use {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.compose-history-use:hover,
.compose-history-use:focus-visible {
  background: #1d1830;
  outline: none;
}

.compose-history-use:focus-visible {
  box-shadow: inset 0 0 0 2px #2aabee66;
}

.compose-history-action {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid #2aabee55;
  background: #1a2836;
  color: #7ec8f0;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.compose-history-use:hover .compose-history-action {
  border-color: #2aabee;
  color: #c9e9ff;
}

.compose-history-media {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #0d0b12;
  border: 1px solid #2a2538;
}

.compose-history-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compose-history-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #2aabee;
  opacity: .85;
}

.compose-history-placeholder svg {
  width: 22px;
  height: 22px;
}

.compose-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: #9b94a8;
  font-size: 12px;
}

.compose-history-tag {
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #ffffff14;
  background: #ffffff08;
  color: #b7b0c4;
  font-size: 11px;
  font-weight: 650;
}

.compose-history-copy p {
  margin: 0;
  color: #e8e4f0;
  font-size: 13px;
  line-height: 1.35;
}

.compose-history-error {
  display: block;
  margin-top: 6px;
  color: #ff8f8f;
}

.compose-history-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 28px 18px;
  border: 1px dashed #353049;
  border-radius: 12px;
  background: #121018;
  text-align: center;
  color: #9b94a8;
}

.compose-history-empty strong {
  color: #e8e4f0;
  font-size: 14px;
}

.compose-history-empty p {
  margin: 0;
  max-width: 32ch;
  font-size: 13px;
  line-height: 1.4;
}

.compose-history-empty-ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: #1a2836;
  color: #2aabee;
}

.compose-history-empty-ico svg {
  width: 20px;
  height: 20px;
}

.compose-history-empty.is-loading {
  border-style: solid;
}

@media (max-width: 680px) {
  .compose-send-row {
    align-items: stretch;
  }

  .compose-send-button {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .settings-split {
    grid-template-columns: 1fr;
  }
  .switch-row {
    align-items: flex-start;
  }
  .telegram-layout,
  .telegram-grid,
  .telegram-link-grid,
  .telegram-channel-row,
  .telegram-event-grid,
  .telegram-template-grid,
  .telegram-stats-card,
  .tg-button-row {
    grid-template-columns: 1fr;
  }
  .tg-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .telegram-preview {
    position: static;
  }
  .telegram-actions .button {
    width: 100%;
  }
}
