/* ============================================================
 * Craft Tools · 界面风格皮肤
 * ------------------------------------------------------------
 * html[data-ui="glass"]     苹果液态玻璃（见 glass.css，默认）
 * html[data-ui="miuix"]     小米 HyperOS / MIUIX
 * html[data-ui="material"]  Android 原生 Material 3
 *
 * 皮肤只覆盖变量和组件细节，不改结构、不改 JS。
 * 新增一套风格 = 复制一个块，改变量 + 几条组件规则。
 * ============================================================ */

/* ============================================================
 * 一、MIUIX（小米 HyperOS）
 * ============================================================ */
html[data-ui="miuix"] {
    --bg: #f2f3f5;
    --bg-deep: #e9eaed;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #eceef2;
    --ink: #000000;
    --ink-soft: #1f2126;
    --text: #000000;
    --muted: #7a7f87;
    --faint: #a8adb5;
    --line: #e6e8ec;
    --line-strong: #d8dbe0;

    --gold: #3482ff;
    --gold-bright: #57a0ff;
    --gold-pale: #cfe2ff;
    --gold-wash: rgba(52, 130, 255, 0.1);

    --accent: #3482ff;
    --accent-ink: #ffffff;
    --accent-soft: rgba(52, 130, 255, 0.12);
    --danger: #e34d59;
    --danger-soft: rgba(227, 77, 89, 0.1);
    --ok: #00a05a;

    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-xl: 28px;

    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.04);
    --sh-2: 0 6px 20px rgba(0, 0, 0, 0.07);
    --sh-3: 0 20px 50px rgba(0, 0, 0, 0.18);

    --font: "MiSans", "MiSans VF", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;

    --glass-a: rgba(255, 255, 255, 0.86);
    --glass-b: rgba(255, 255, 255, 0.7);
    --glass-c: rgba(255, 255, 255, 0.8);
    --glass-edge: rgba(255, 255, 255, 0.9);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

html[data-ui="miuix"][data-theme="dark"] {
    --bg: #000000;
    --bg-deep: #000000;
    --surface: #1a1a1c;
    --surface-2: #232326;
    --surface-3: #2c2c30;
    --ink: #f2f3f5;
    --ink-soft: #ffffff;
    --text: #f2f3f5;
    --muted: #9aa0a8;
    --faint: #6b6f76;
    --line: #2e2e33;
    --line-strong: #3a3a40;
    --gold: #4a90ff;
    --accent: #4a90ff;
    --accent-ink: #ffffff;
    --accent-soft: rgba(74, 144, 255, 0.2);
    --glass-a: rgba(40, 40, 44, 0.86);
    --glass-b: rgba(40, 40, 44, 0.7);
    --glass-c: rgba(52, 52, 58, 0.8);
    --glass-edge: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* 顶栏：半透明 + 模糊（HyperOS 的观感） */
html[data-ui="miuix"] .appbar {
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom-color: transparent;
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    backdrop-filter: blur(24px) saturate(1.4);
}

/* 底栏：悬浮、圆角更大、纯模糊（不折射） */
html[data-ui="miuix"] .tabs {
    border-radius: var(--r-xl);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}
html[data-ui="miuix"] .tabs__pill {
    --pill-inset: 3px;
    border: none;
    border-radius: var(--r-lg);
    background: var(--accent-soft);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
html[data-ui="miuix"] .tabs__btn[aria-current="page"] .tabs__icon { color: var(--accent); }

/* 卡片：扁平 + 细边（HyperOS 的列表观感） */
html[data-ui="miuix"] .card {
    box-shadow: none;
    border-color: var(--line);
    border-radius: var(--r-lg);
}
html[data-ui="miuix"] .card:hover {
    box-shadow: var(--sh-2);
    transform: none;
}
html[data-ui="miuix"] .card__glyph { border: none; background: var(--surface-3); }

/* 按钮：胶囊实心蓝 */
html[data-ui="miuix"] .btn { border-radius: var(--r-pill); border-color: transparent; background: var(--surface-3); }
html[data-ui="miuix"] .btn--primary { background: var(--accent); color: var(--accent-ink); }
html[data-ui="miuix"] .btn--ghost { background: var(--surface-2); border-color: var(--line); }

/* 分段控件 */
html[data-ui="miuix"] .segmented { border-radius: var(--r-pill); background: var(--surface-3); border-color: transparent; }
html[data-ui="miuix"] .segmented button { border-radius: var(--r-pill); }
html[data-ui="miuix"] .segmented button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--accent);
}

/* 开关：HyperOS 的宽扁样式 */
html[data-ui="miuix"] .switch { width: 50px; height: 30px; }
html[data-ui="miuix"] .switch__track::after { width: 24px; height: 24px; }
html[data-ui="miuix"] .switch input:checked + .switch__track { background: var(--accent); }
html[data-ui="miuix"] .switch input:checked + .switch__track::after { transform: translateX(20px); }

/* 分类行、筛选小胶囊 */
html[data-ui="miuix"] .catrow { border-color: var(--line); box-shadow: none; }
html[data-ui="miuix"] .chip { border-color: transparent; background: var(--surface-3); }
html[data-ui="miuix"] .chip[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* 弹层 */
html[data-ui="miuix"] .sheet { border-radius: var(--r-xl); border-color: transparent; }

/* ============================================================
 * 二、Material 3（Android 原生）
 * ============================================================ */
html[data-ui="material"] {
    --bg: #fef7ff;
    --bg-deep: #f3edf7;
    --surface: #ffffff;
    --surface-2: #f7f2fa;
    --surface-3: #ece6f0;
    --ink: #1d1b20;
    --ink-soft: #2b2831;
    --text: #1d1b20;
    --muted: #49454f;
    --faint: #79747e;
    --line: #cac4d0;
    --line-strong: #938f99;

    --gold: #6750a4;
    --gold-bright: #7f67be;
    --gold-pale: #eaddff;
    --gold-wash: #e8def8;

    --accent: #6750a4;
    --accent-ink: #ffffff;
    --accent-soft: #e8def8;
    --danger: #b3261e;
    --danger-soft: #f9dedc;
    --ok: #146c2e;

    --r-xs: 4px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 28px;

    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.1);
    --sh-2: 0 1px 3px 1px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.12);
    --sh-3: 0 4px 12px rgba(0, 0, 0, 0.16);

    --font: Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;

    --glass-a: #ffffff;
    --glass-b: #ffffff;
    --glass-c: #ffffff;
    --glass-edge: transparent;
    --glass-shadow: none;
}

html[data-ui="material"][data-theme="dark"] {
    --bg: #141218;
    --bg-deep: #141218;
    --surface: #211f26;
    --surface-2: #2b2930;
    --surface-3: #36343b;
    --ink: #e6e0e9;
    --ink-soft: #f5eff7;
    --text: #e6e0e9;
    --muted: #cac4d0;
    --faint: #938f99;
    --line: #49454f;
    --line-strong: #79747e;
    --gold: #d0bcff;
    --gold-bright: #eaddff;
    --gold-wash: #4f378b;
    --accent: #d0bcff;
    --accent-ink: #381e72;
    --accent-soft: #4f378b;
    --glass-a: #211f26;
    --glass-b: #211f26;
    --glass-c: #211f26;
}

/* 顶栏：Material 是实心 + 高度投影，没有模糊 */
html[data-ui="material"] .appbar {
    background: var(--bg);
    border-bottom-color: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 底栏：贴底整条（NavigationBar），不再是悬浮胶囊 */
/* 底部留 8px：手机浏览器底部工具栏会盖住视口最下面那条，贴底 0 会被裁掉 */
html[data-ui="material"] .tabs {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--r-lg);
    padding: 4px;
    height: 64px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--sh-2);
}
html[data-ui="material"] .tabs__pill {
    --pill-inset: 9px;
    top: 8px;
    bottom: auto;
    height: 32px;
    border: none;
    border-radius: 16px;
    background: var(--accent-soft);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
html[data-ui="material"] .tabs__btn {
    font-weight: 500;
    letter-spacing: 0.01em;
}
html[data-ui="material"] .tabs__btn[aria-current="page"] { color: var(--text); }
html[data-ui="material"] .tabs__btn[aria-current="page"] .tabs__icon { color: var(--gold); }

/* 卡片：M3 的 elevation + 16 圆角，无描边 */
html[data-ui="material"] .card {
    border-color: transparent;
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2);
}
html[data-ui="material"] .card:hover { transform: none; box-shadow: var(--sh-3); }
html[data-ui="material"] .card__glyph {
    border: none;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--gold);
}

/* 按钮：M3 filled / outlined，20 圆角，带水波纹 */
html[data-ui="material"] .btn {
    border-radius: 20px;
    overflow: hidden;
    font-weight: 500;
    letter-spacing: 0.01em;
    background: var(--surface-3);
    border-color: transparent;
}
html[data-ui="material"] .btn--primary { background: var(--accent); color: var(--accent-ink); }
html[data-ui="material"] .btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
html[data-ui="material"] .btn--ghost { background: transparent; border-color: var(--line); }
html[data-ui="material"] .btn--ghost:hover { background: var(--surface-2); }

/* 筛选胶囊：outlined chip */
html[data-ui="material"] .chip {
    border-radius: var(--r-sm);
    border-color: var(--line);
    background: transparent;
    overflow: hidden;
}
html[data-ui="material"] .chip[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--text);
    font-weight: 600;
}

/* 分段控件：M3 segmented button */
html[data-ui="material"] .segmented {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 2px;
}
html[data-ui="material"] .segmented button {
    border-radius: var(--r-pill);
    color: var(--muted);
}
html[data-ui="material"] .segmented button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--text);
    box-shadow: none;
}

/* 开关：M3 尺寸 */
html[data-ui="material"] .switch { width: 52px; height: 32px; }
html[data-ui="material"] .switch__track { border-radius: 16px; background: var(--surface-3); border: 2px solid var(--line); }
html[data-ui="material"] .switch__track::after {
    width: 16px; height: 16px;
    top: 6px; left: 6px;
    background: var(--muted);
}
html[data-ui="material"] .switch input:checked + .switch__track {
    background: var(--accent);
    border-color: var(--accent);
}
html[data-ui="material"] .switch input:checked + .switch__track::after {
    width: 24px; height: 24px;
    top: 2px; left: 2px;
    background: var(--accent-ink);
    transform: translateX(20px);
}

/* 分类行 */
html[data-ui="material"] .catrow { border-color: transparent; box-shadow: var(--sh-1); }
html[data-ui="material"] .catrow__glyph { background: var(--accent-soft); color: var(--gold); }

/* 弹层：M3 的 bottom sheet */
html[data-ui="material"] .sheet-overlay { align-items: flex-end; padding: 0; }
html[data-ui="material"] .sheet {
    max-width: none;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border: none;
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    animation: sheetUp 0.28s var(--ease);
}
@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: none; }
}
html[data-ui="material"] .spec { background: var(--surface-2); border-color: transparent; }

/* 输入框 */
html[data-ui="material"] .search input,
html[data-ui="material"] .input { border-radius: var(--r-xs) var(--r-xs) 4px 4px; }
html[data-ui="material"] .search input:focus,
html[data-ui="material"] .input:focus { box-shadow: 0 0 0 1px var(--accent) inset; }

/* ============================================================
 * 水波纹（只在安卓风格下）
 * ============================================================ */
.rp {
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.18;
    transform: scale(0);
    pointer-events: none;
    animation: rp 0.55s ease-out forwards;
}
@keyframes rp {
    to { transform: scale(1); opacity: 0; }
}
