/* 首页「我的工具」卡片区 + header 账号入口（wp-my-tools v0.1.0）
 * 配色引子主题 --mcp-* 变量（dv 先例），fallback 保证独立可用 */

/* ---------- header 账号入口 ---------- */
.mt-user {
  /* 「最上最右侧」：脱离模板布局流，锚定视口右上。各域模板 logo 行宽度
   * 不一（首页 space-between 全宽 / 子主题仅内容宽，推到行尾也只到页面
   * 中部），flex 方案无法跨域对齐；absolute 统一解决。无 positioned 祖先
   * 时包含块为初始包含块（文档顶 + 视口宽），随页头滚出视口。
   * top 36 = 五域实测 logo 行垂直基线一致值。margin:0 压 WP 布局引擎
   * 对 group 子项的 margin 归零残余（原 inline 流内 margin 已无意义）。 */
  position: absolute;
  top: 36px;
  right: clamp(12px, 2.5vw, 48px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
  white-space: nowrap;
}
.mt-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--mcp-ink, #0e402d);
  border-radius: 50%;
}
.mt-user-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--mcp-ink, #0e402d);
  /* a 化（点击进个人设置）：压掉主题全局链接样式，hover 下划线暗示可点 */
  text-decoration: none;
  cursor: pointer;
}
.mt-user-name:hover { text-decoration: underline; }
.mt-user-link {
  font-size: 13.5px;
  color: #3c4038;
  text-decoration: none;
}
.mt-user-link:hover { color: var(--mcp-ink, #0e402d); text-decoration: underline; }
.mt-user-login {
  padding: 5px 14px;
  font-weight: 600;
  color: #fff;
  background: var(--mcp-ink, #0e402d);
  border-radius: 999px;
}
.mt-user-login:hover { color: #fff; text-decoration: none; opacity: 0.9; }

/* ---------- 卡片区容器（不写 max-width：跟随 #top-new-banner 父容器，任何视口与 banner 恒等宽） ---------- */
.mt-section {
  padding: 6px 24px 8px;
}
.mt-head {
  display: flex;
  align-items: center;
  gap: 14px;
  /* 上方间距由 banner 原生 margin-bottom(1.2em) 提供，这里只补 6px——
   * 原先 18px 叠出 ~37px「上松下紧」节奏失衡（视觉评审） */
  margin: 6px 0 16px;
}
.mt-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--wp--preset--color--contrast, #111);
}
.mt-toolbar {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ---------- 工具钮 ---------- */
.mt-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mcp-ink, #0e402d);
  background: #fff;
  border: 1px solid var(--mcp-line, #e6e6e1);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.mt-btn:hover { border-color: var(--mcp-ink, #0e402d); }
.mt-btn-ghost { color: #565b52; }
.mt-btn-primary {
  color: #fff;
  background: var(--mcp-ink, #0e402d);
  border-color: var(--mcp-ink, #0e402d);
}
.mt-btn-primary:hover { opacity: 0.9; }

/* ---------- 卡片网格 ---------- */
.mt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.mt-card-item {
  position: relative;
  display: flex;
  align-items: center;
}
.mt-card {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--mcp-line, #e6e6e1);
  border-radius: var(--mcp-card-radius, 14px);
  box-shadow: var(--mcp-shadow, 0 1px 2px rgba(17, 17, 17, 0.04));
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
a.mt-card:hover {
  transform: translateY(-2px);
  border-color: rgba(14, 64, 45, 0.35);
  box-shadow: var(--mcp-shadow-hover, 0 6px 18px -8px rgba(17, 17, 17, 0.12));
}
/* 首字彩色徽章：底/字色由 JS 按卡位轮换注入（inline），结构尺寸在这 */
.mt-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  border-radius: 10px;
}
.mt-card-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--wp--preset--color--contrast, #111);
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.mt-card:hover .mt-card-title { color: var(--mcp-ink, #0e402d); }
.mt-badge {
  flex: none;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #5b3df5;
  background: #f1edfe;
  border-radius: 999px;
}

/* 编辑态 */
.mt-grip {
  flex: none;
  padding: 0 2px;
  font-size: 13px;
  color: #767b71;
  cursor: grab;
  transition: color 0.15s ease;
}
.mt-grip:hover { color: #454a41; }
.mt-grip:active { cursor: grabbing; }
.mt-del {
  position: absolute;
  top: -7px;
  right: -7px;
  display: none;
  width: 22px;
  height: 22px;
  font-size: 15px;
  line-height: 1;
  color: #fff;
  background: #c4372f;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.mt-card-item .mt-del { display: flex; }
.mt-card-item.sortable-ghost { opacity: 0.4; }
.mt-empty {
  grid-column: 1 / -1;
  padding: 26px 18px;
  font-size: 14px;
  color: var(--mcp-muted, #6b6f66);
  background: #fff;
  border: 1px dashed var(--mcp-line, #e6e6e1);
  border-radius: var(--mcp-card-radius, 14px);
  text-align: center;
}

/* ---------- 刷新防跳预留（随本样式表在 head 阻塞渲染，参与首帧） ----------
 * JS 在 head 同步执行挂 html.mtjs + 设 --mt-reserve（localStorage 上次实测
 * 位移，无缓存回退 343 = banner 原生 margin 19.2 + 匿名 12 卡区 324，
 * 2026-09-19 图标徽章化后实测校准），
 * DOMContentLoaded 挂上实体后同 tick 摘类，预留→实体无缝交接；
 * JS 禁用/失败时无 mtjs 类，不留空隙。
 * 默认值含 margin：实体态 banner 的 margin-bottom 1.2em 与 mt-section 相邻
 * 不再折叠，预留只算卡区高会差 19px 残跳。 */
html.mtjs #top-new-banner { padding-bottom: var(--mt-reserve, 343px); }
/* 预留/卡片区会把右列撑高，左列 is-vertically-aligned-center（垂直居中）
 * 会把分类树推到 columns 中部（实测下移 159px）。:has 精准命中含词云
 * banner 的这个 columns，不影响全站其他居中列 */
html.mtjs .wp-block-columns:has(#top-new-banner) > .wp-block-column.is-vertically-aligned-center,
.wp-block-columns:has(.mt-section) > .wp-block-column.is-vertically-aligned-center {
  align-self: flex-start;
}
/* 老浏览器 :has 兜底：JS 挂载时给左列打的类 */
.mt-align-top { align-self: flex-start; }

/* ---------- 首访骨架（fetch 前占位，paint 前同步挂载防跳动） ----------
 * 复用 .mt-card 盒模型保证与真卡同高；shimmer 只是弱动效提示加载中 */
.mt-skel { pointer-events: none; }
.mt-skel-icon,
.mt-skel-line {
  display: inline-block;
  border-radius: 999px;
  background: linear-gradient(100deg, #eeece7 40%, #f6f5f1 50%, #eeece7 60%);
  background-size: 200% 100%;
  animation: mt-shimmer 1.4s linear infinite;
}
.mt-skel-icon { width: 34px; height: 34px; border-radius: 10px; }
.mt-skel-line { height: 13px; }
/* 骨架 cta 行高对齐真文 21px 行高，骨架态与实体态总高一致（防 8px 微跳） */
.mt-cta .mt-skel-line { height: 21px; width: 40%; }
@keyframes mt-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mt-skel-icon, .mt-skel-line { animation: none; }
}

/* 匿名引导条 */
.mt-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600; /* 视觉评审：浅绿底上灰绿字对比度不足近乎不可读 */
  color: #08281b;
  background: linear-gradient(90deg, rgba(160, 219, 192, 0.55), rgba(160, 219, 192, 0.2));
  border-radius: var(--mcp-card-radius, 14px);
}
.mt-cta-btn {
  margin-left: auto;
  padding: 7px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: var(--mcp-ink, #0e402d);
  border-radius: 999px;
}
.mt-cta-btn:hover { color: #fff; opacity: 0.9; }

/* ---------- CPT 详情页收藏按钮 ---------- */
.mt-collect {
  margin: 12px 0 0;
}
.mt-collect-btn {
  font-size: 13.5px;
}
.mt-collect-btn.is-in {
  color: #565b52;
  background: #f3f5f1;
  border-color: var(--mcp-line, #e6e6e1);
  cursor: default;
}
.mt-collect-btn.is-in:hover {
  border-color: var(--mcp-line, #e6e6e1);
}

/* ---------- 添加面板 ---------- */
.mt-add-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 17, 0.45);
}
.mt-add-panel {
  width: min(480px, 100%);
  max-height: 82vh;
  overflow: auto;
  padding: 20px 22px 22px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(17, 17, 17, 0.35);
}
.mt-add-head {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}
.mt-add-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--wp--preset--color--contrast, #111);
}
.mt-add-close {
  margin-left: auto;
  padding: 2px 8px;
  font-size: 20px;
  color: #8b8f86;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.mt-add-close:hover { color: #33362f; background: #f3f4f0; }
.mt-add-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.mt-add-tab {
  min-width: 92px;
  padding: 6px 16px;
  font-size: 13.5px;
  text-align: center;
  font-weight: 600;
  color: var(--mcp-muted, #6b6f66);
  background: #fff;
  border: 1px solid var(--mcp-line, #e6e6e1);
  border-radius: 999px;
  cursor: pointer;
}
.mt-add-tab.is-on {
  color: #fff;
  background: var(--mcp-ink, #0e402d);
  border-color: var(--mcp-ink, #0e402d);
}
.mt-add-body { min-height: 120px; }
.mt-add-search { margin-bottom: 10px; }
.mt-add-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--mcp-line, #e6e6e1);
  border-radius: 10px;
  outline: none;
}
.mt-add-input:focus { border-color: var(--mcp-ink, #0e402d); }
.mt-add-custom { display: grid; gap: 10px; }
.mt-add-custom .mt-btn { justify-self: start; }
.mt-add-hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--mcp-muted, #6b6f66);
}
.mt-add-results { display: grid; gap: 6px; }
.mt-add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  text-align: left;
  background: #fafaf7;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.mt-add-row:hover { background: #f1f5ef; border-color: rgba(14, 64, 45, 0.25); }
.mt-add-row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  color: #2c2f2a;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- toast ---------- */
.mt-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 100000;
  padding: 10px 22px;
  font-size: 14px;
  color: #fff;
  background: rgba(28, 30, 26, 0.92);
  border-radius: 999px;
  box-shadow: 0 10px 26px -8px rgba(17, 17, 17, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.mt-toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .mt-section { padding: 6px 14px 8px; }
  .mt-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .mt-card-icon { width: 28px; height: 28px; font-size: 13px; border-radius: 8px; }
  /* 窄卡图标已区分类型，徽章隐藏把空间让给名称（否则截断到「一…」级） */
  .mt-badge { display: none; }
  .mt-cta-btn { margin-left: 0; }
  .mt-user { gap: 8px; }
  .mt-user-avatar { width: 24px; height: 24px; font-size: 12px; }
}
