/*! 定制版 UI 适配补丁 v1.2  (2026-11-29)
 *  只覆盖样式，不修改构建产物结构。
 *  撤销方式：删掉本文件 + index.html 里的 <link> 即可完全还原。
 *
 *  v1.1 修复：v1.0 用裸 `aside` 选择器修饰左侧导航，误伤了业务页面里的 <aside>
 *  （如「自动化规则」左栏模板列表），把 `space-y-3` 容器强制成 flex row，
 *  导致模板卡片挤成一条竖排文字。此处改用具名类 `inset-y-0` 锁定真正的导航栏。
 *  v1.2：「自动化规则」在 1024–1279 宽时退回单列，模板卡片独占整屏、
 *  规则列表被推到首屏之外；把双栏断点提前到 lg，视口不变形。
 */

/* ========== 1. 品牌标识（仅左侧导航栏） ========== */
/* 导航栏底部原本渲染构建号（main-4f4fcb0 4f4fcb0f3c61），对使用者无意义，换成产品名。 */
aside[class*="inset-y-0"] span.font-mono {
  font-size: 0 !important;
  line-height: 1.7;
  letter-spacing: 0;
}
aside[class*="inset-y-0"] span.font-mono:last-child::after {
  content: "定制版";
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgb(var(--color-muted));
}

/* ========== 2. 暗色主题层次 ========== */
/* 原本导航栏与画布只差 10 级明度，边界几乎不可辨，加一层侧向阴影与边框提亮 */
[data-theme="dark"] aside[class*="inset-y-0"] {
  border-right-color: rgb(var(--color-line) / .6);
  box-shadow: 1px 0 0 rgb(255 255 255 / .04), 24px 0 56px -32px rgb(0 0 0 / .85);
}
/* 暗色下卡片与画布的层次也偏弱，靠极浅描边拉开 */
[data-theme="dark"] main .rounded-2xl,
[data-theme="dark"] main .rounded-3xl {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .045);
}

/* ========== 3. 移动端安全区 ========== */
/* 主滚动容器（就是 <main>，它带着底部导航高度的内边距变量）顶部让出状态栏高度，
   避免标题贴住屏幕边缘 */
@media (max-width: 1023px) {
  main[class*="mobile-nav-height"] {
    padding-top: max(1.25rem, env(safe-area-inset-top));
  }
}

/* ========== 4. 滚动条统一 ========== */
* {
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--color-line) / .9) transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgb(var(--color-line) / .85);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--color-muted) / .8);
  background-clip: content-box;
}

/* ========== 5. 窄屏与触屏 ========== */
/* 表格类容器在窄屏允许惯性横滑，不再整页横向抖动 */
@media (max-width: 1023px) {
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
}
@media (max-width: 380px) {
  main h1 {
    font-size: 1.375rem;
    line-height: 1.9rem;
  }
}

/* ========== 6. 自动化规则页：双栏断点提前 ========== */
/* 页面原本只在 xl(1280) 以上排成「模板 | 规则」两栏，1024–1279 时左栏模板
   独占整宽，规则列表被挤到首屏之外。这里把该容器在 lg 段也排成两栏。 */
@media (min-width: 1024px) and (max-width: 1279.98px) {
  div[class*="xl:grid-cols-[minmax(270px"] {
    grid-template-columns: minmax(300px, 0.68fr) minmax(0, 1fr);
  }
}

/* ========== 7. 移动端顶部操作区 ========== */
/* 手机宽度下「下拉 + 刷新 + 主按钮」被压成三行，刷新独占一行且居中悬空。
   改成下拉独占一行、两个按钮并排各半，纵向少一行。 */
@media (max-width: 639.98px) {
  main div[class*="sm:flex-row"]:has(> select) {
    flex-direction: row;
    flex-wrap: wrap;
  }
  main div[class*="sm:flex-row"]:has(> select) > select {
    flex: 1 0 100%;
  }
  main div[class*="sm:flex-row"]:has(> select) > button {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* ========== 8. 可访问性 ========== */
/* 键盘导航时给出清晰焦点环（鼠标点击不出现） */
:focus-visible {
  outline: 2px solid rgb(var(--color-brand));
  outline-offset: 2px;
  border-radius: 8px;
}
/* 尊重系统"减少动态效果" */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* iOS 横屏不再自动放大字号 */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
