/* The message menu takes over after its event listeners are attached. The
   fallback controls have no visual space or Tab stops in that state. */
[data-kf-message-menu].kf-message-menu-bound .ma-strip { display: none !important; }

/* Shared Telegram-style context surface. */
.kf-context-menu,
.kf-context-edit {
  --kf-context-bg: #fff;
  --kf-context-fg: #263746;
  --kf-context-muted: #64798b;
  --kf-context-border: #dae3eb;
  --kf-context-hover: #edf5fc;
  --kf-context-accent: #2787cd;
  --kf-context-danger: #c53e47;
  --kf-context-danger-bg: #fff0f1;
  box-sizing: border-box;
  background: var(--kf-context-bg);
  color: var(--kf-context-fg);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid var(--kf-context-border);
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(22, 51, 76, .12);
}
.kf-context-menu {
  position: fixed;
  z-index: 2147483000;
  width: max-content;
  min-width: 188px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  display: block;
  margin: 0;
  padding: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.kf-context-menu .kf-context-item {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 8px 11px;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-transform: none;
  text-decoration: none;
  white-space: normal;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.kf-context-menu .kf-context-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: var(--kf-context-muted);
}
.kf-context-menu .kf-context-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kf-context-menu .kf-context-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.kf-context-menu .kf-context-item:focus-visible,
.kf-context-menu .kf-context-item:active {
  outline: none;
  background: var(--kf-context-hover);
}
.kf-context-menu .kf-context-item:focus-visible {
  outline: 1px solid var(--kf-context-accent);
  outline-offset: -2px;
}
@media (hover: hover) {
  .kf-context-menu .kf-context-item:hover {
    background: var(--kf-context-hover);
  }
}
.kf-context-menu .kf-context-item.is-danger,
.kf-context-menu .kf-context-item.is-danger .kf-context-icon {
  color: var(--kf-context-danger);
}
.kf-context-menu .kf-context-item.is-danger:focus-visible,
.kf-context-menu .kf-context-item.is-danger:active {
  background: var(--kf-context-danger-bg);
}
@media (hover: hover) {
  .kf-context-menu .kf-context-item.is-danger:hover {
    background: var(--kf-context-danger-bg);
  }
}
.kf-context-menu .kf-context-item[aria-disabled="true"] {
  opacity: .45;
  cursor: default;
}
.kf-context-menu .kf-context-item[aria-disabled="true"]:hover,
.kf-context-menu .kf-context-item[aria-disabled="true"]:active {
  background: transparent;
}
.kf-context-menu .kf-context-divider {
  box-sizing: border-box;
  height: 1px;
  margin: 4px 7px;
  padding: 0;
  background: var(--kf-context-border);
}

/* Optional shared text editor: a native modal with no HTML interpretation. */
.kf-context-edit {
  position: fixed;
  inset: 0;
  width: min(440px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  height: fit-content;
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.kf-context-edit::backdrop {
  background: rgba(18, 39, 57, .38);
}
.kf-context-edit .kf-context-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  margin: 0;
  padding: 18px;
}
.kf-context-edit .kf-context-edit-title {
  margin: 0;
  color: inherit;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.45;
}
.kf-context-edit .kf-context-edit-description,
.kf-context-edit .kf-context-edit-count,
.kf-context-edit .kf-context-edit-label,
.kf-context-edit .kf-context-edit-error {
  margin: 0;
  color: var(--kf-context-muted);
  font-size: 13px;
  line-height: 1.4;
}
.kf-context-edit .kf-context-edit-label {
  color: var(--kf-context-fg);
  font-weight: 600;
}
.kf-context-edit .kf-context-edit-field {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 88px;
  max-height: 45vh;
  margin: 0;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--kf-context-border);
  border-radius: 7px;
  background: var(--kf-context-bg);
  color: var(--kf-context-fg);
  box-shadow: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
}
.kf-context-edit .kf-context-edit-field:focus {
  border-color: var(--kf-context-accent);
  outline: 1px solid var(--kf-context-accent);
}
.kf-context-edit .kf-context-edit-count { text-align: right; }
.kf-context-edit .kf-context-edit-error {
  color: var(--kf-context-danger);
  overflow-wrap: anywhere;
}
.kf-context-edit .kf-context-edit-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 3px 0 0;
}
.kf-context-edit .kf-context-edit-footer button {
  box-sizing: border-box;
  min-width: 72px;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--kf-context-border);
  border-radius: 7px;
  background: var(--kf-context-bg);
  color: var(--kf-context-fg);
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  text-transform: none;
}
.kf-context-edit .kf-context-edit-footer .kf-context-edit-save {
  border-color: var(--kf-context-accent);
  background: var(--kf-context-accent);
  color: #fff;
}
.kf-context-edit .kf-context-edit-footer button:focus-visible {
  outline: 2px solid var(--kf-context-accent);
  outline-offset: 2px;
}
.kf-context-edit .kf-context-edit-footer button:disabled {
  opacity: .6;
  cursor: default;
}
.kf-context-edit [hidden] { display: none !important; }
@media (max-width: 600px) {
  .kf-context-menu .kf-context-item { min-height: 46px; }
  .kf-context-edit .kf-context-edit-form { padding: 14px; }
}
