/* Readable controls on narrow screens and at larger Telegram text scales. */
.segment-tabs .segment-btn, .audience-segmented-bar .segment-btn {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
  height: auto;
  min-height: 44px;
}
.segment-btn svg { flex: none; }
.pill-btn {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
  min-height: 44px;
}
.btn-template-bar {
  min-height: 44px;
  height: auto;
  line-height: 1.3;
}
.btn-template-bar span:not(.template-badge-chip) {
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
}
#opBotEditorView, #viewCreate, #viewProfile { container-type: inline-size; }
@container (max-width: 390px) {
  #opEditorTabs { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 340px) {
  #tzButtonsGrid { grid-template-columns: 1fr; }
  #channelSearchBar { display: grid; grid-template-columns: 44px minmax(0, 1fr); }
  #channelSearchBar .search-input-wrap { grid-column: 1 / -1; min-width: 0; }
  #channelSearchBar .btn-add-ch-glass { width: 100%; }
}
/* Inputs need room for their hints; type and upload controls sit on the next line. */
#botSectionWelcome div:has(> .bot-media-type),
#botSectionDelivery div:has(> .bot-media-type) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#botSectionWelcome div:has(> .bot-media-type) > input,
#botSectionDelivery div:has(> .bot-media-type) > input { grid-column: 1 / -1; min-width: 0; }
#botSectionWelcome .bot-media-type, #botSectionDelivery .bot-media-type { max-width: none; width: 100%; min-height: 44px; }
#botSectionWelcome div:has(> .bot-media-type) > button,
#botSectionDelivery div:has(> .bot-media-type) > button { min-width: 0; min-height: 44px; height: auto; }
@container (max-width: 500px) {
  #formAddChOpen > div:has(> #inpAddCbotTitleOpen),
  #formAddChClosed > div:has(> #inpAddCbotChannelClosedId),
  #formAddChClosed > div:has(> #inpAddCbotChannelClosedLink) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  #formAddChOpen > div:has(> #inpAddCbotTitleOpen) > button,
  #formAddChClosed > div:has(> #inpAddCbotChannelClosedLink) > button { width: 100%; min-height: 44px; }
}
/* Navigation and scenario labels remain readable even when the app is magnified. */
.scenarios-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 88px), 1fr)); }
.scenario-name, .scenario-desc { white-space: normal; overflow-wrap: anywhere; line-height: 1.3; text-overflow: clip; }
.dock-tab-btn { flex: 1 1 0; min-width: 0; }
.dock-tab-btn .dock-label { display: block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.1; text-align: center; }
@media (max-width: 430px) {
  .wizard-progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 8px 12px; }
  .wizard-step-line { display: none; }
  .wizard-step-node { min-width: 0; flex-direction: column; gap: 4px; text-align: center; }
  .wizard-step-node span { white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
}
@container (max-width: 390px) {
  #botSectionTraffers div:has(> #inpNewTrafferName) { display: grid; grid-template-columns: minmax(0, 1fr); }
  #botSectionTraffers div:has(> #inpNewTrafferName) > button { min-height: 44px; }
}
.dock-inner { container-type: inline-size; gap: 0; }
.dock-tab-btn .dock-label { font-size: clamp(9px, 3.8cqw, 11px); letter-spacing: -0.02em; }

.dock-tab-btn { padding-inline: 0; }
.dock-tab-btn:nth-child(4) { flex-grow: 1.2; }
.dock-tab-btn:nth-child(5) { flex-grow: 1.05; }
/* Channel connection dialog: keep the input and action readable on phones. */
@media (max-width: 600px) {
  #addChannelModal div:has(> #addChannelInput) { display: grid; grid-template-columns: minmax(0, 1fr); }
  #addChannelInput, #btnSubmitAddChannel { width: 100%; min-width: 0; }
}
#addChannelModal .btn-primary-action { height: auto; min-height: 44px; padding: 9px 12px; line-height: 1.3; white-space: normal; background: var(--accent-gradient); color: #17120a; font-weight: 700; border: 0; }
#addChannelModal .btn-secondary-action { min-height: 44px; }
@container (max-width: 340px) {
  #botSectionWelcome div:has(> button[onclick="saveCurrentBotSettings()"]) { display: grid; grid-template-columns: minmax(0, 1fr); }
}
button[data-seq-name] { display: block; min-width: 0; height: auto; white-space: normal; line-height: 1.3; }
#addChannelInput { padding-left: 12px; }