/* 選択テキストの見た目（任意） */
.af-kaisetu-comment {
  border-bottom: 1px solid #ff0000;
  cursor: help;
  position: relative;
}

/* アクティブ状態（編集中）のハイライト */
.af-kaisetu-comment.is-active {
  background-color: rgba(33, 150, 243, 0.1);
  border-radius: 2px;
  padding: 1px 2px;
  box-shadow: 0 0 0 1px rgba(33, 150, 243, 0.3);
}

/* アンカー要素の基本スタイル */
.af-kaisetu-anchor {
  display: inline;
  position: relative;
}

/* アンカー要素の after で解説ボックスを表示 */
.af-kaisetu-anchor::after {
  content: attr(data-kaisetsu);
  position: absolute;
  bottom: calc(-1.7em - 2px);
  left: -1px;
  padding: 2px 2px 2px 0;
  border-radius: 4px;
  font-size: .7rem;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 2;
  background-color: rgba(255, 255, 255, 0.5); /* 白を50%透過 */
  color: #ff0000;
}

/* エディター用：元の .af-kaisetu-comment::after も残す（アンカーがない場合のフォールバック） */
.editor-styles-wrapper .af-kaisetu-comment::after {
  content: attr(data-kaisetsu);
  position: absolute;
  bottom: calc(-1.7em - 2px);
  left: -1px;
  padding: 2px 2px 2px 0;
  border-radius: 4px;
  font-size: .7rem;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 2;
  background-color: rgba(255, 255, 255, 0.5); /* 白を50%透過 */
  color: #ff0000;
}

/* エディター内でアンカーがある場合は親の after を非表示 */
.editor-styles-wrapper .af-kaisetu-comment:has(.af-kaisetu-anchor)::after {
  display: none;
}

/* 編集中の永続的ハイライト */
.editor-styles-wrapper .af-kaisetu-comment[data-editing="true"] {
  background-color: rgba(33, 150, 243, 0.2) !important;
  padding: 2px 4px !important;
  position: relative !important;
}

/* マスク機能のスタイル */
/* マスク状態（初期：赤で塗りつぶし） */
.maskred {
  background: #d31d1d;          /* 赤い塗りつぶし */
  color: #d31d1d;
  transition: background .3s, color .3s;  /* 0.3秒に延長してゆっくり変化 */
  -webkit-tap-highlight-color: transparent;
  outline: none;                 /* フォーカス枠は必要に応じて調整 */
  margin: 0 2px;
  animation: maskFadeIn 0.3s ease-in-out;  /* マスク適用時のフェードイン */
}

/* マスク解除時のフェードインアニメーション */
@keyframes maskFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* マスク解除時のフェードアウトアニメーション */
@keyframes maskFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* 解除条件：ホバー／フォーカス（タップでフォーカスする端末向け）／アクティブ */
.maskred:hover,
.maskred:focus,
.maskred:active {
  background: transparent;       /* 塗りを外す */
  cursor: none; 
}

/* 編集画面の見栄え */
.editor-styles-wrapper .maskred {
  background: #FFEBEE;           /* 薄い赤い背景 */
  color: #d31d1d;                /* 赤い文字色 */
}

.editor-styles-wrapper .maskred:hover,
.editor-styles-wrapper .maskred:focus,
.editor-styles-wrapper .maskred:active {
  cursor: default;
}
