/* ============================================================
 * leakey の 小窝 · 增强模块样式 (enhance)
 * ============================================================
 * 所有选择器以 .enh- 开头，不与原页面冲突。
 * 颜色一律引用页面已有的 CSS 变量（--card-bg / --text-1 / --accent …），
 * 因此自动跟随 6 套主题，不需要重复定义配色。
 * ============================================================ */

/* ---------- 1. 背景图层 ---------- */
/* 用独立 fixed 图层，不修改 body 的 background，
   因此与原有 applyTheme() 完全并存，互不干扰。
   z-index:-1 让它位于内容之下、body 背景之上。 */
.enh-bg-layer,
.enh-bg-image {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    /* 增强：补上 background 过渡 —— 时段切换时渐变平滑淡入，不再是硬切 */
    transition: opacity .45s ease, background 1.2s ease;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
/* 遮罩：--enh-dim 由 JS 挂在 <html> 上（0 = 不遮）。
   注意它只在自己所属的图层可见时才有效 —— 图层 opacity 为 0 时整层都不渲染。 */
.enh-bg-layer::after,
.enh-bg-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, var(--enh-dim, 0));
    transition: background .3s ease;
}
/* 只有对应模式激活时图层才可见。
   JS 已保证：图片模式下没有图片会退回 theme，不会出现「空图层」 */
body.enh-bg-time  .enh-bg-layer,
body.enh-bg-solid .enh-bg-layer,
body.enh-bg-image .enh-bg-image { opacity: 1; }

/* ---------- 2. 天气动效 ---------- */
.enh-fx {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity .6s ease;
}
.enh-fx-on { opacity: 1; }

.enh-fx-p {
    position: absolute;
    top: -12vh;
    display: block;
    animation-name: enh-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform;
}
@keyframes enh-fall {
    from { transform: translateY(0); }
    to   { transform: translateY(125vh); }
}

/* 雨丝 */
.enh-fx-rain {
    width: 1px;
    height: 14px;
    background: linear-gradient(to bottom, transparent, rgba(170, 215, 255, .6));
}
/* 雷阵雨：更密更长 */
.enh-fx-storm {
    width: 1px;
    height: 20px;
    background: linear-gradient(to bottom, transparent, rgba(160, 205, 255, .75));
}
/* 雪花 */
.enh-fx-snow {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    box-shadow: 0 0 4px rgba(255, 255, 255, .6);
}
/* 云：横向漂移的柔和光斑 */
.enh-fx-cloud {
    width: 26vw;
    height: 12vh;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, .28), transparent 70%);
    animation-name: enh-drift;
    top: auto;
    top: 6vh;
}
@keyframes enh-drift {
    from { transform: translateX(-30vw); }
    to   { transform: translateX(130vw); }
}

/* 晴天：右上角一圈暖光 */
.enh-fx-sun::before {
    content: '';
    position: absolute;
    top: -14vh;
    right: -10vw;
    width: 46vw;
    height: 46vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 226, 150, .40), rgba(255, 210, 120, .12) 45%, transparent 70%);
    animation: enh-pulse 7s ease-in-out infinite;
}
@keyframes enh-pulse {
    0%, 100% { opacity: .75; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.06); }
}

/* 系统要求减少动效时，全部停掉（只留静态背景） */
@media (prefers-reduced-motion: reduce) {
    .enh-fx { display: none !important; }
    .enh-bg-layer, .enh-bg-image { transition: none; }
}

/* ---------- 3. 极简模式 ---------- */
body.enh-minimal .top-bar > *:not(.enh-keep) { opacity: .25; }

/* ---------- 4. 布局编辑 ---------- */
.enh-drag-handle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin: -4px -4px 6px;
    border-radius: 8px;
    cursor: grab;
    color: var(--text-3, #889);
    font-size: 14px;
    letter-spacing: 2px;
    background: var(--input-bg, rgba(255, 255, 255, .5));
    touch-action: none;
    user-select: none;
}
.enh-drag-handle:active { cursor: grabbing; }
.enh-drag-handle:hover { color: var(--accent, #5bb8d4); }

.enh-hide-toggle {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 5px;
    border: 1px dashed var(--card-border, rgba(120, 150, 200, .3));
    border-radius: 8px;
    background: transparent;
    color: var(--text-3, #889);
    font-size: 12px;
    cursor: pointer;
}
.enh-hide-toggle:hover { color: var(--accent, #5bb8d4); border-color: var(--accent, #5bb8d4); }

/* 手柄上的一行文字提示（只有编辑模式会创建它） */
.enh-drag-tip { font-size: 11px; letter-spacing: 0; font-weight: 400; opacity: .8; }

/* 手柄可 Tab 聚焦，焦点必须看得见 */
.enh-drag-handle:focus-visible {
    outline: 2px solid var(--accent, #5bb8d4);
    outline-offset: 1px;
}

/* ---------- 隐藏卡片 ----------
   ⚠️ 修复：原先这里**只有** `body.enh-layout-edit .xxx { opacity: .4 }` 一条，
      普通模式没有任何规则 —— 所以点完「完成编辑」后，被隐藏的卡片又原样显示了，
      「隐藏卡片」这个功能等于没生效。
      现在：普通模式真正 display:none；编辑模式重新显示出来并变淡，方便点「显示」再取消。 */
.sidebar-widget.enh-card-hidden { display: none; }

/* 编辑模式下给卡片描边，明确「现在可以拖」 */
body.enh-layout-edit .sidebar-widget {
    outline: 1px dashed var(--accent, #5bb8d4);
    outline-offset: 2px;
}
body.enh-layout-edit .sidebar-widget.enh-card-hidden { display: block; opacity: .4; }

/* 拖拽进行中：整页禁止选中，避免拖出一路蓝色选区 */
body.enh-dragging { user-select: none; -webkit-user-select: none; }
body.enh-dragging * { cursor: grabbing !important; }

/* ---------- 编辑模式工具条 ----------
   原先没有任何批量入口，隐藏几张后想全部恢复只能一张张点回来。 */
.enh-layout-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
    border-radius: 12px;
    border: 1px solid var(--card-border, rgba(100, 180, 220, .25));
    background: var(--card-bg, rgba(255, 255, 255, .9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 20px rgba(30, 70, 100, .12);
}
.enh-lb-count {
    flex: 1;
    min-width: 0;
    font-size: 11.5px;
    color: var(--text-3, #7aa8c0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.enh-lb-btn {
    flex: none;
    padding: 5px 12px;
    border-radius: 9px;
    border: 1px solid var(--card-border, rgba(100, 180, 220, .3));
    background: transparent;
    color: var(--text-2, #4a7a94);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}
.enh-lb-btn:hover { color: var(--accent, #5bb8d4); border-color: var(--accent, #5bb8d4); }
.enh-lb-done {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent, #5bb8d4), var(--accent-2, #3a9fc0));
}
.enh-lb-done:hover { color: #fff; filter: brightness(1.06); }

.enh-drag-ghost {
    border-radius: 12px;
    background: var(--card-bg, rgba(255, 255, 255, .7));
    box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
    opacity: .9;
    outline: 1px solid var(--accent, #5bb8d4);
}

/* ---------- 5. 控制面板 ---------- */
.enh-fab {
    position: fixed;
    right: 18px;
    bottom: 96px;
    z-index: 900;
    width: 44px;
    height: 44px;
    border: 1px solid var(--card-border, rgba(120, 150, 200, .25));
    border-radius: 50%;
    background: var(--card-bg, rgba(255, 255, 255, .8));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--text-1, #2d4a5e);
    font-size: 19px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .13);
    transition: transform .22s, box-shadow .22s;
}
.enh-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 10px 26px rgba(0, 0, 0, .18); }

.enh-panel {
    position: fixed;
    right: 18px;
    bottom: 150px;
    z-index: 901;
    width: 330px;
    max-height: min(72vh, 620px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--card-border, rgba(120, 150, 200, .25));
    border-radius: 18px;
    background: var(--card-bg, rgba(255, 255, 255, .88));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .2);
    color: var(--text-1, #2d4a5e);
    font-size: 13px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(.98);
    transition: opacity .22s, transform .22s, visibility .22s;
}
.enh-panel.show { opacity: 1; visibility: visible; transform: none; }

.enh-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--card-border, rgba(120, 150, 200, .18));
    font-weight: 600;
}
.enh-close {
    border: none;
    background: transparent;
    color: var(--text-3, #889);
    font-size: 15px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}
.enh-close:hover { color: var(--text-1, #2d4a5e); background: var(--input-bg, rgba(0, 0, 0, .05)); }

.enh-panel-body { overflow-y: auto; padding: 4px 16px 16px; }

.enh-sec { padding: 13px 0; border-bottom: 1px solid var(--card-border, rgba(120, 150, 200, .13)); }
.enh-sec:last-child { border-bottom: none; }
.enh-sec h4 {
    margin: 0 0 9px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 7px;
}
.enh-tag {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-3, #889);
    background: var(--input-bg, rgba(0, 0, 0, .05));
    padding: 1px 7px;
    border-radius: 20px;
}

.enh-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.enh-chip {
    padding: 5px 10px;
    border: 1px solid var(--card-border, rgba(120, 150, 200, .28));
    border-radius: 20px;
    background: transparent;
    color: var(--text-2, #4a7a94);
    font-size: 12px;
    cursor: pointer;
    transition: all .18s;
    white-space: nowrap;
}
.enh-chip:hover { border-color: var(--accent, #5bb8d4); color: var(--accent, #5bb8d4); }
.enh-chip.on {
    background: var(--accent, #5bb8d4);
    border-color: var(--accent, #5bb8d4);
    color: #fff;
}
/* 「安装为应用」等不可点的 chip（已安装 / 浏览器不给自动安装入口） */
.enh-chip:disabled { opacity: .55; cursor: default; }
.enh-chip:disabled:hover { border-color: var(--card-border, rgba(120, 150, 200, .28)); color: var(--text-2, #4a7a94); }
.enh-chip kbd {
    font-size: 10px;
    padding: 0 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .25);
}

.enh-btn {
    width: 100%;
    padding: 9px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent, #5bb8d4), var(--accent-2, #3a9fc0));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .18s, box-shadow .18s;
}
.enh-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(90, 180, 210, .3); }
.enh-btn.on { animation: enh-rec .9s ease-in-out infinite; }
.enh-btn:disabled { opacity: .6; cursor: default; transform: none; }
@keyframes enh-rec {
    0%, 100% { box-shadow: 0 0 0 0 rgba(224, 112, 112, .5); }
    50%      { box-shadow: 0 0 0 8px rgba(224, 112, 112, 0); }
}

.enh-input {
    width: 100%;
    margin: 8px 0;
    padding: 7px 10px;
    border: 1px solid var(--card-border, rgba(120, 150, 200, .28));
    border-radius: 9px;
    background: var(--input-bg, rgba(255, 255, 255, .6));
    color: var(--text-1, #2d4a5e);
    font-size: 12px;
    outline: none;
}
.enh-input:focus { border-color: var(--accent, #5bb8d4); }

.enh-lab {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-size: 12px;
    color: var(--text-2, #4a7a94);
}
.enh-lab input[type="range"] { flex: 1; accent-color: var(--accent, #5bb8d4); }

.enh-color {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--card-border, rgba(120, 150, 200, .28));
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
}

.enh-switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; }
.enh-switch input { accent-color: var(--accent, #5bb8d4); }

.enh-file {
    display: inline-block;
    margin-top: 6px;
    padding: 5px 10px;
    border: 1px dashed var(--card-border, rgba(120, 150, 200, .35));
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-2, #4a7a94);
    cursor: pointer;
}
.enh-file:hover { border-color: var(--accent, #5bb8d4); color: var(--accent, #5bb8d4); }

.enh-hint {
    margin-top: 7px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-3, #889);
}

.enh-voice-result {
    margin-top: 9px;
    padding: 9px 11px;
    border-radius: 10px;
    background: var(--input-bg, rgba(0, 0, 0, .05));
    font-size: 12px;
    line-height: 1.7;
}
.enh-voice-text { color: var(--text-3, #889); }
.enh-voice-parse { font-weight: 600; margin: 4px 0 8px; }

/* ---------- 6. 窄屏适配 ---------- */
/* v3.10.10：手机/平板上主页右下角还有 📋「小组件」悬浮球
   （index.css 的 .mobile-widgets-fab：right 14 / bottom 84 + 安全区 / 48×48，z-index 165），
   而原本 ✨ 就在 right 12 / bottom 88，两个球几乎完全重叠、✨ 还盖在上面。
   这里把 ✨ 抬到 📋 上方 12px（84 + 48 + 12 = 144），右边缘与它对齐；
   面板同步抬高到 196（144 + 44 + 8），并用 calc 限制高度，保证小屏上不会顶出视口。 */
@media (max-width: 1100px) {
    .enh-fab { right: 14px; bottom: calc(144px + env(safe-area-inset-bottom, 0px)); }
    .enh-panel {
        right: 14px;
        bottom: calc(196px + env(safe-area-inset-bottom, 0px));
        max-height: calc(100vh - 220px);
    }
}
@media (max-width: 520px) {
    .enh-panel { right: 8px; left: 8px; width: auto; max-height: calc(100vh - 250px); }
}

/* ===== 无障碍：尊重系统「减少动态效果」（v3.10.9）===== */
@media (prefers-reduced-motion: reduce) {
    *,*::before,*::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    .enh-btn.on { animation: none !important; }
    .enh-fx-* { animation: none !important; }
}
