/* 文章容器：保留換行、設定定位基準 */
#mas-content {
  line-height: 1.8;
  font-size: 18px;
  padding: 20px;
  white-space: pre-wrap;
  position: relative;
  color: #333;
}

/* 基礎樣式：共用設定 */
.mas-highlight {
  border-bottom: 2px solid transparent;
  cursor: pointer;
  position: relative;
  display: inline;
  transition: background-color 0.2s ease;
}

/* 1. 他人的標註（預設顯示灰色） */
.mas-highlight.others {
  background-color: #eeeeee !important; /* 淺灰色底 */
  border-bottom: 1px dashed #bdbdbd !important;
  color: #555;
}

/* 2. 自己的標註（使用 RGBA 保持半透明，確保重疊時能透出底色） */
.mas-highlight.mine {
  background-color: rgba(255, 241, 118, 0.85) !important; /* 85% 不透明黃色 */
  border-bottom: 2px solid #fbc02d !important;
  z-index: 1;
  /* 💡 新增這行：讓後續透過 JS 加入的 outline 變化有平滑動畫 */
  transition:
    outline 0.3s ease,
    background-color 0.2s ease;
}

/* 3. 關鍵重疊邏輯：當 mine 包著 others 時 */
.mas-highlight.mine .mas-highlight.others {
  /* 讓內層的 others 背景透明，避免遮擋外層的黃色，但保留其虛線特徵 */
  background-color: rgba(0, 0, 0, 0.05) !important;
  border-bottom: 1px dashed #666 !important;
}

/* 💡 新增：確保移入時，該標註（連同它的氣泡）會浮到最前面 */
.mas-highlight:hover {
  z-index: 1000 !important;
}

/* 4. 滑鼠移入效果：區分身分變色 */
.mas-highlight.mine:hover {
  background-color: #fff176 !important; /* 移入時變為純黃色 */
}

.mas-highlight.others:hover {
  background-color: #d1d1d1 !important; /* 移入他人標註變深灰色 */
}

/* Tooltip 黑色氣泡 */
.mas-highlight::after {
  content: attr(data-comment);
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 8px;

  background: #222;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  z-index: 9999;
  white-space: pre-wrap;

  min-width: 120px;
  max-width: 280px;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

  display: none;
  pointer-events: none;
}

/* 只有當 data-comment 存在且「不是空字串」時，hover 才顯示 */
.mas-highlight[data-comment]:not([data-comment=""]):hover::after {
  display: block;
}

/* --- 修改處：Toolbar 命名變更 --- */
.mas-toolbar {
  background: #222;
  padding: 6px 10px;
  border-radius: 5px;
  display: flex;
  gap: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition:
    top 0.1s ease-out,
    left 0.1s ease-out;
  pointer-events: auto;
  z-index: 10001 !important; /* 提高權重 */
}

/* 💡 新增：當顯示按鈕時，讓按鈕橫向排隊 */
.mas-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 💡 新增：登入提示的文字顏色 */
.mas-login-tip {
  color: #fff;
  font-size: 13px;
  padding: 4px 8px;
}

.mas-toolbar button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}

/* --- 修改處：Comment Box 命名變更 --- */
.mas-comment-box {
  background: #fff;
  border: 1px solid #ddd;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 260px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10002 !important; /* 比工具列更高 */
  position: absolute; /* 確保它是絕對定位 */
}

.mas-comment-box textarea {
  width: 100%;
  height: 90px;
  border: 1px solid #eee;
  padding: 8px;
  font-size: 14px;
  resize: none;
  display: block;
  box-sizing: border-box;
  border-radius: 4px;
  background-color: #f9f9f9;
}

.mas-comment-box button {
  background: #222;
  color: #fff;
  border: none;
  width: 100%;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

/* 註解輸入框容器 */
/* --- 修改處：Comment Box 命名變更 --- */
.mas-comment-box {
  background: #fff;
  border: 1px solid #ddd;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 260px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mas-comment-box textarea {
  width: 100%;
  height: 90px;
  border: 1px solid #eee;
  padding: 8px;
  font-size: 14px;
  resize: none;
  display: block;
  box-sizing: border-box;
  border-radius: 4px;
  background-color: #f9f9f9;
}

.mas-comment-box button {
  background: #222;
  color: #fff;
  border: none;
  width: 100%;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

.btn-delete:hover {
  background-color: #fff1f1 !important;
  transform: scale(1.1);
  transition: all 0.2s;
}

/* 💡 新增這個類別：專門給書箋跳轉時瞬間醒目用 */
/* 💡 修改：跳轉目標的醒目效果 */
.bookmark-target {
  /* 使用金黃色底色，與紅色的 🔖 按鈕做出區隔 */
  background-color: #fff176 !important;
  /* 使用深橘色邊框，比純紅色更柔和且明顯 */
  outline: 4px solid #ff9800 !important;
  outline-offset: 2px;
  border-radius: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
}

#mas-jump-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  /* 💡 改為黃色漸變：從金黃到深橘黃 */
  background: linear-gradient(135deg, #ffeb3b, #fbc02d);
  color: #5d4037; /* 深咖啡色文字/圖示，在黃底下比白色更清楚 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  font-size: 26px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid #fff; /* 加個白色細邊框會更精緻 */
}

#mas-jump-btn:hover {
  transform: scale(1.1) rotate(10deg); /* 滑過時稍微轉一下，增加動感 */
  background: linear-gradient(135deg, #fff176, #ffb300);
}

/* 預設隱藏，有書箋時才透過 JS 移除此類別 */
.mas-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}
/* Toast 訊息容器 */
.mas-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(50, 50, 50, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 10001;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none; /* 確保不會擋到點擊 */
}

.mas-toast.fade-out {
  opacity: 0;
  transform: translate(-50%, -20px);
}
