/* 前台补充样式（Tailwind 之外的少量定制） */
:root { --brand: #4f46e5; }
html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .rtl\:rotate-180 { transform: rotate(180deg); }

/* 工具卡片悬浮 */
.tool-card { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.tool-card:hover { transform: translateY(-3px); box-shadow: 0 10px 25px -5px rgba(16,24,40,.12); border-color: #c7d2fe; }

/* 工具 iframe 自适应高度容器 */
.tool-frame-wrap { background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; overflow: hidden; }
.tool-frame-wrap iframe { width: 100%; border: 0; min-height: 640px; display: block; }

/* 分类图标底色轮换 */
.cat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }

/* 后台侧边栏当前项 */
.admin-nav a.active { background: #eef2ff; color: #4338ca; font-weight: 600; }

/* 简单淡入 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .35s ease both; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid #eef0f4; text-align: start; }
table.data th { background: #f8fafc; color: #475569; font-weight: 600; white-space: nowrap; }
table.data tr:hover td { background: #fafbff; }

/* 表单控件 */
.form-label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-input, .form-textarea, .form-select {
  width: 100%; border: 1px solid #d8dee9; border-radius: 10px; padding: 9px 12px; font-size: 14px;
  background: #fff; color: #1e293b; outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: #818cf8; box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-brand { background: #eef2ff; color: #4338ca; }

/* ============================================================
   前台专属：背景方格 + 毛玻璃卡片（视觉体系移植）
   所有规则都以 body.tt-app 作用域隔离；后台布局的 <body> 不带
   tt-app，因此这里的一切对 admin 零影响。
   ============================================================ */

/* 1) 固定方格底纹层：全站网格只在这一个层绘制，杜绝双层错位重影。
      body 自身仍由 Tailwind 的 bg-slate-50(#f8fafc) 提供纯色底。 */
.tt-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}
.tt-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 42, 72, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 42, 72, .045) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%);
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}
@media (max-width: 767px) {
  .tt-grid { background-size: 40px 40px; }
  .tt-amb { filter: blur(6px); }
  .tt-cat-blob { filter: blur(7px); }
}

/* 1b) 渐变半透明光斑（ambient blobs）：三枚大尺寸柔焦圆，固定在网格层、内容之下，
       用靛蓝/紫/青三色径向渐变缓慢漂移，毛玻璃卡片会透出它们的色彩。
       全部 rgba 实现，不依赖 color-mix，兼容性更好。 */
.tt-amb {
  position: absolute;
  width: 64vmax;
  height: 64vmax;
  border-radius: 50%;
  opacity: .42;
  will-change: transform;
  filter: blur(8px);
  pointer-events: none;
}
/* 左侧透镜：品牌靛蓝 */
.tt-amb-a {
  top: 6%;
  left: -22vmax;
  background: radial-gradient(closest-side,
    rgba(79, 70, 229, .30) 0%, rgba(79, 70, 229, .16) 45%, rgba(79, 70, 229, .05) 66%, transparent 78%);
  animation: ttDriftA 38s ease-in-out infinite alternate;
}
/* 中央光斑：紫罗兰 */
.tt-amb-b {
  top: -16vmax;
  left: 50%;
  margin-left: -32vmax;
  background: radial-gradient(closest-side,
    rgba(124, 58, 237, .32) 0%, rgba(124, 58, 237, .14) 46%, transparent 76%);
  animation: ttDriftB 46s ease-in-out infinite alternate;
}
/* 右侧透镜：青色，略淡 */
.tt-amb-c {
  bottom: -14vmax;
  right: -22vmax;
  opacity: .34;
  background: radial-gradient(closest-side,
    rgba(6, 182, 212, .30) 0%, rgba(6, 182, 212, .13) 46%, transparent 78%);
  animation: ttDriftC 54s ease-in-out infinite alternate;
}
@keyframes ttDriftA { to { transform: translate3d(10vmax, 8vmax, 0) scale(1.12); } }
@keyframes ttDriftB { to { transform: translate3d(-8vmax, 10vmax, 0) scale(.94); } }
@keyframes ttDriftC { to { transform: translate3d(-9vmax, -8vmax, 0) scale(1.1); } }
@media (prefers-reduced-motion: reduce) {
  .tt-amb-a, .tt-amb-b, .tt-amb-c { animation: none; }
}

/* 1c) 分类专属光斑（category / tool 详情页）：颜色由 body 上的 --tt-cat-rgb 驱动，
       14 个分类各自不同。两枚同色透镜分居左上、右下、错位漂移，营造层次而不喧宾夺主。
       全部 rgba(var(--tt-cat-rgb), α) 实现，不依赖 color-mix。 */
.tt-cat-blob {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  opacity: .4;
  will-change: transform;
  filter: blur(10px);
  pointer-events: none;
}
.tt-cat-blob-1 {
  top: -18vmax;
  left: -24vmax;
  background: radial-gradient(closest-side,
    rgba(var(--tt-cat-rgb, 79, 70, 229), .30) 0%,
    rgba(var(--tt-cat-rgb, 79, 70, 229), .15) 46%,
    rgba(var(--tt-cat-rgb, 79, 70, 229), .05) 66%, transparent 78%);
  animation: ttCatDrift1 42s ease-in-out infinite alternate;
}
.tt-cat-blob-2 {
  bottom: -20vmax;
  right: -26vmax;
  width: 62vmax;
  height: 62vmax;
  opacity: .34;
  background: radial-gradient(closest-side,
    rgba(var(--tt-cat-rgb, 79, 70, 229), .28) 0%,
    rgba(var(--tt-cat-rgb, 79, 70, 229), .13) 48%, transparent 76%);
  animation: ttCatDrift2 52s ease-in-out infinite alternate;
}
@keyframes ttCatDrift1 { to { transform: translate3d(12vmax, 9vmax, 0) scale(1.12); } }
@keyframes ttCatDrift2 { to { transform: translate3d(-11vmax, -9vmax, 0) scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .tt-cat-blob-1, .tt-cat-blob-2 { animation: none; }
}
/* 内容浮于方格层之上。刻意不写 header：它自带 sticky + z-40，
   低特异性规则若改其 z-index 会让语言菜单等下拉被正文盖住。 */
body.tt-app main,
body.tt-app footer { position: relative; z-index: 1; }

/* 2) 毛玻璃卡片：品牌靛蓝调（呼应 tailwind.config 的 brand #4f46e5）。
      圆角不强制统一，保留各元素原有的 rounded-* 尺寸。
      白度由 .72 降到 .63：内页卡片不再"太白"，背后的分类光斑/方格能透上来；
      取 .63 而非更低，是让描述文字 slate-500 在典型光斑区仍满足 WCAG AA 4.5:1
      （实测等效底对比度 4.51），标题 16+、正文 7+ 余量充足。 */
body.tt-app .tool-card,
body.tt-app .tt-glass {
  background-color: rgba(255, 255, 255, .63);
  -webkit-backdrop-filter: saturate(165%) blur(14px);
  backdrop-filter: saturate(165%) blur(14px);
  border: 1px solid rgba(79, 70, 229, .14);
  box-shadow: 0 12px 34px -18px rgba(30, 27, 75, .28);
}
/* 玻璃卡 hover：保留原有上浮位移，底色更实、边框转该工具所属分类色（--tt-cat，
   由 tool_card 内联注入；未注入时回退品牌浅靛蓝），阴影加深 */
body.tt-app .tool-card:hover {
  background-color: rgba(255, 255, 255, .78);
  border-color: var(--tt-cat, #c7d2fe);
  box-shadow: 0 18px 42px -18px rgba(30, 27, 75, .38);
}
/* hover 时分类图标块轻微放大，强化交互反馈 */
body.tt-app .tool-card:hover .cat-icon { transform: translateY(-1px) scale(1.06); }
body.tt-app .cat-icon { transition: transform .18s ease; }
/* iframe 工具容器内部保持纯白、不玻璃化，确保第三方工具页面的对比度与可读性；
   仅给外框加一层当前分类色柔边与柔光阴影，让详情页与分类光斑色调呼应（--tt-cat-rgb
   只在分类/详情页的 body 上存在，缺省回退品牌靛蓝）。 */
body.tt-app .tool-frame-wrap {
  background-color: #fff;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-color: rgba(var(--tt-cat-rgb, 79, 70, 229), .22);
  box-shadow: 0 16px 40px -22px rgba(var(--tt-cat-rgb, 79, 70, 229), .45);
}
