/* ============================================================
   网址导航 · 前台样式
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-soft: #5b6b7d;
    --text-faint: #9aa8b6;
    --border: #e5e7eb;
    --bg: #f5f7fb;
    --card-bg: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(17, 24, 39, .06);
    --shadow-hover: 0 8px 24px rgba(37, 99, 235, .12);
    --chip-bg: rgba(255, 255, 255, .85);
    --chip-border: rgba(255, 255, 255, .9);
    --hover-soft: #f1f5f9;
    --divider: #c9d5e0;
    /* 背景场景：主题切换时只替换这两个变量 */
    --scene-color: #e9f6fe;
    --scene-image: url("../images/bg.svg");
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--scene-color);
    background-image: var(--scene-image);
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }
.hide { display: none !important; }

/* ============================================================
   整体配色主题（前台右下角切换，选择记忆在浏览器 localStorage）
   每套主题 = 背景场景（--scene-*）+ 界面主色（--primary-*）。
   夜间主题额外通过 body.theme-front 把前台文字/卡片切为深色，
   登录/注册/个人后台保持白色卡片，避免控件配色错乱。
   ============================================================ */
html[data-theme="sakura"] {
    --primary: #ec4899;
    --primary-dark: #db2777;
    --primary-soft: #fdf2f8;
    --shadow-hover: 0 8px 24px rgba(236, 72, 153, .14);
    --scene-color: #fdeef4;
    --scene-image: url("../images/bg-sakura.svg");
}

html[data-theme="ocean"] {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-soft: #f0f9ff;
    --shadow-hover: 0 8px 24px rgba(14, 165, 233, .15);
    --scene-color: #e2f4fd;
    --scene-image: url("../images/bg-ocean.svg");
}

html[data-theme="sunset"] {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-soft: #fff7ed;
    --shadow-hover: 0 8px 24px rgba(249, 115, 22, .16);
    --scene-color: #fdeedc;
    --scene-image: url("../images/bg-sunset.svg");
}

html[data-theme="night"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-soft: rgba(129, 140, 248, .16);
    --shadow: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow-hover: 0 8px 24px rgba(129, 140, 248, .22);
    --scene-color: #0b1424;
    --scene-image: url("../images/bg-night.svg");
}

/* 夜间主题仅作用于前台首页：文字变浅、卡片/弹层变深 */
html[data-theme="night"] body.theme-front {
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --text-soft: #aab8ca;
    --text-faint: #7e8ca3;
    --divider: rgba(255, 255, 255, .18);
    --border: #334155;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --chip-bg: rgba(10, 18, 34, .62);
    --chip-border: rgba(148, 163, 184, .35);
}

/* ---------------- 配色切换器 ---------------- */
.theme-switch {
    position: fixed;
    right: 18px;
    bottom: 74px;
    z-index: 90;
}

.theme-fab {
    width: 46px;
    height: 46px;
    border: 1px solid var(--chip-border);
    border-radius: 50%;
    background: var(--chip-bg);
    box-shadow: var(--shadow);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all .2s;
}

.theme-fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.theme-panel {
    position: absolute;
    right: 0;
    bottom: 58px;
    width: 240px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(17, 24, 39, .18);
    padding: 12px;
}

.theme-panel[hidden] { display: none; }

.theme-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-light);
    margin: 0 2px 9px;
}

.theme-opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.theme-opt {
    border: 2px solid transparent;
    border-radius: 10px;
    background: none;
    padding: 4px 4px 6px;
    cursor: pointer;
    font: inherit;
    text-align: center;
    transition: border-color .15s, background .15s;
}

.theme-opt:hover { background: var(--hover-soft); }

.theme-opt.active { border-color: var(--primary); }

.theme-opt .swatch {
    display: block;
    height: 42px;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .08);
}

.theme-opt .t-name {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
}

.theme-opt.active .t-name { color: var(--primary); font-weight: 600; }

/* ---------------- 顶部栏 ---------------- */
.topbar {
    background: transparent;
    position: relative;
}

.user-area {
    position: absolute;
    top: 16px;
    right: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 90;
}

/* 用户头像：悬停展开下拉（进入后台 / 退出登录） */
.user-menu { position: relative; }

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    user-select: none;
    overflow: hidden;
    background: var(--card-bg);
    border: 2px solid var(--chip-border);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .12);
    transition: box-shadow .2s, transform .2s;
}

.user-avatar img { width: 100%; height: 100%; display: block; border-radius: 50%; }

.user-avatar:hover { box-shadow: 0 4px 16px rgba(37, 99, 235, .22); transform: translateY(-1px); }

.user-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    padding-top: 10px; /* 透明连接区，鼠标移动时不会丢失悬停 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .18s, transform .18s, visibility .18s;
    z-index: 80;
}

.user-menu:hover .user-dropdown,
.user-menu:focus-within .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.ud-box {
    min-width: 160px;
    padding: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}

.ud-name {
    max-width: 200px;
    padding: 8px 12px 7px;
    margin-bottom: 4px;
    font-size: 12.5px;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.ud-item svg { width: 16px; height: 16px; display: block; flex-shrink: 0; }

.ud-item:hover { background: var(--primary-soft); color: var(--primary); }

.bar-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 26px;
    padding-bottom: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.logo-ico { font-size: 30px; }

.search {
    width: 100%;
    display: flex;
    align-items: center;
    border: 2px solid var(--primary);
    border-radius: 999px;
    background: #fff;
    transition: box-shadow .2s;
    padding-right: 4px;
}

.search:focus-within { box-shadow: 0 0 0 4px rgba(37, 99, 235, .15); }

/* 搜索引擎下拉：左侧显示当前引擎图标，点击弹出引擎菜单 */
.engine-drop {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    align-self: stretch;
    padding-left: 14px;
}

.engine-cur {
    display: flex;
    align-items: center;
    gap: 3px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background .15s;
}

.engine-cur:hover { background: var(--primary-soft); }

.engine-cur img { width: 24px; height: 24px; border-radius: 5px; display: block; }

.engine-caret { width: 10px; height: 10px; fill: #64748b; transition: transform .15s; }

.engine-drop.open .engine-caret { transform: rotate(180deg); }

.engine-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 6px;
    z-index: 70;
    width: 156px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(17, 24, 39, .14);
    padding: 6px;
}

.engine-menu[hidden] { display: none; }

.engine-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 7px;
    font: inherit;
    font-size: 14px;
    color: #1f2937; /* 下拉菜单始终白底，不随深色主题变化 */
    cursor: pointer;
    text-align: left;
}

.engine-opt img { width: 20px; height: 20px; border-radius: 4px; flex: none; }

.engine-opt:hover { background: var(--hover-soft); }

.engine-opt.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }

.engine-opt.active::after { content: '✓'; margin-left: auto; font-size: 13px; }

.search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 10px 0 2px;
    font-size: 16px;
    min-width: 0;
}

/* 只作用于搜索提交按钮（>）：右侧圆形放大镜图标按钮，去掉原来的文字块 */
.search > button {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    transition: background .18s;
}

.search > button svg { width: 22px; height: 22px; }

.search > button:hover { background: var(--primary-soft); }

/* ---------------- 搜索框 ---------------- */
/* 行内布局：宽度为内容列的 90%，居中；高度由 --search-h 统一控制 */
.search-row {
    --search-h: 55px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 14px;
    width: 100%;
    max-width: 90%;
}

.search-row .search { height: var(--search-h); }

/* ---------------- 顶部时钟 + 天气 ---------------- */
.clock-bar {
    display: flex;
    align-items: stretch; /* 天气卡片自动拉伸到与左侧时间模块等高 */
    justify-content: center;
    gap: 40px;
    width: 100%;
}

.clock-main { text-align: center; text-decoration: none; display: block; }

/* 时钟可点击：悬停时间变主色，提示跳转百度日历 */
a.clock-main { color: inherit; }
a.clock-main:hover .clock-time, a.clock-main:focus-visible .clock-time { color: var(--primary); }

.clock-time {
    font-size: 54px;
    font-weight: 700;
    line-height: 1.1;
    height: 59px; /* 归一化行高，供右侧太阳+温度行按同一高度带对齐 */
    color: var(--text);
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
}

.clock-date {
    margin-top: 4px;
    font-size: 13px;
    line-height: 20px;
    height: 20px;
    color: var(--text-soft);
}

.clock-date .dot { margin: 0 8px; color: var(--text-faint); }

/* 天气模块：无背景，与左侧时间模块等高（.clock-bar stretch）。
   结构分两段：wc-top（温度）与 .clock-time 同高居中（与时间对齐），
   wc-desc（城市 | 天气 | 风向风力）与 .clock-date（年月 周X）同一行高、同字号同色，底部对齐 */
.weather-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* wc-top 贴顶、wc-desc 钉底 */
    color: var(--text);
}

/* 分割线：位于时间与天气之间，通到顶部与底部对齐 */
.weather-card::before {
    content: '';
    position: absolute;
    left: -21px; /* 居中于 .clock-bar 的 40px 间距内 */
    top: 0;
    bottom: 0;
    width: 2px;
    border-radius: 1px;
    background: var(--divider);
}

.wc-top {
    height: 59px; /* 与 .clock-time 同高：太阳+温度在时间的高度带内居中 */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 城市名按钮化（可点击打开选择城市弹层）：继承文字外观，仅加悬停反馈 */
.wc-city {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: top; /* 与同行文字共用 20px 行框，顶部对齐避免基线偏移 */
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
}

.wc-city svg { width: 13px; height: 13px; fill: currentColor; flex-shrink: 0; }
.wc-city:hover span, .wc-city:focus-visible span { color: var(--primary); }
.wc-caret { width: 10px !important; height: 10px !important; opacity: .55; transition: transform .15s ease; }
.wc-city[aria-expanded="true"] .wc-caret { transform: rotate(180deg); opacity: .8; }

/* 选择城市弹层：锚定天气卡片底部居中 */
.city-picker {
    position: absolute;
    top: calc(100% + 8px);
    right: 50%;
    transform: translateX(50%);
    z-index: 60;
    width: 252px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(17, 24, 39, .14);
    padding: 12px;
    text-align: left;
}
.city-picker[hidden] { display: none; }
.cp-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.cp-row { display: flex; gap: 8px; }
.cp-row select {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg);
    cursor: pointer;
}
.cp-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.cp-btn {
    font: inherit;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-light);
    cursor: pointer;
}
.cp-btn:hover { border-color: #9db4c8; color: var(--text); }
.cp-btn.cp-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.cp-btn.cp-primary:hover { background: var(--primary-dark); color: #fff; }
.cp-btn:disabled { opacity: .55; cursor: default; }

.wc-main { display: flex; align-items: center; justify-content: center; gap: 10px; }

.wc-icon { width: 34px; height: 34px; flex-shrink: 0; }

.wc-temp {
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.wc-unit { font-size: 15px; font-weight: 600; margin-left: 1px; }

/* 与 .clock-date（年月 周X）同字号、同色、同一行高，形成同一行对齐 */
.wc-desc {
    font-size: 13px;
    font-weight: 400;
    line-height: 20px;
    height: 20px;
    color: var(--text-soft);
    white-space: nowrap;
    text-align: center;
}

.wc-sep { margin: 0 8px; color: var(--text-faint); }

/* 天气/温度可点击：跳转百度天气详情 */
.wc-main { text-decoration: none; }
.wc-main:hover .wc-temp, .wc-main:focus-visible .wc-temp { color: var(--primary); }
.wc-type { color: inherit; text-decoration: none; }
.wc-type:hover, .wc-type:focus-visible { color: var(--primary); }

/* ---------------- 主体 ---------------- */
.main { flex: 1; padding-top: 6px; padding-bottom: 40px; }

/* ---------------- 分类筛选条 ---------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 18px;
}

.chip {
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    color: var(--text-light);
    font-size: 13.5px;
    padding: 6px 18px;
    border-radius: 16px;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
}

.chip:hover { color: var(--primary); border-color: var(--primary); }

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.grid-empty {
    display: none;
    text-align: center;
    color: var(--text-light);
    padding: 40px 0;
    font-size: 14px;
}

/* 网址卡片：每行固定 10 个 */
.grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 10px;
}

.site-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    padding: 14px 6px 10px;
    text-decoration: none;
    color: var(--text);
    transition: all .2s;
    min-width: 0;
}

.site-card:hover {
    transform: translateY(-3px);
}

.site-card:hover .site-name { color: var(--primary); }

.site-card.hide-by-search { display: none; }

.site-ico {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    flex-shrink: 0;
    object-fit: contain;
    background: #fff;
}

.site-ico.letter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    user-select: none;
}

.site-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 空状态 */
.empty-page { text-align: center; padding: 80px 20px; color: var(--text-light); }
.empty-page .sub { font-size: 14px; margin-top: 10px; }
.empty-page a { color: var(--primary); }
.empty { color: var(--text-light); font-size: 13.5px; padding: 10px 2px; }

/* ---------------- 页脚 ---------------- */
.footer {
    text-align: center;
    padding: 22px 16px 26px;
    color: var(--text-light);
    font-size: 13px;
    line-height: 2;
}

.footer a { color: var(--text-light); }

.footer-logo {
    display: block;
    height: 40px;
    width: auto;
    margin: 0 auto 4px;
}

/* ---------------- 用户网址管理后台（左右布局） ---------------- */
.up-layout {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding-top: 18px;
    padding-bottom: 50px;
}

.up-side {
    width: 212px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, .9);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px 12px 12px;
    position: sticky;
    top: 16px;
}

.up-side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 3px;
    transition: all .15s;
}

.up-side-nav a:hover { background: rgba(37, 99, 235, .08); color: var(--primary); }

.up-side-nav a.active {
    background: linear-gradient(120deg, #2563eb, #3b82f6);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(37, 99, 235, .3);
}

.up-side-nav .nav-ico { font-size: 15px; width: 20px; text-align: center; }
.up-side-nav .nav-ico svg,
.up-side-foot .nav-ico svg { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }
.up-side-nav a.active .nav-ico svg { filter: brightness(0) invert(1); }

/* 用户名标识：位于侧边栏顶部，图标与文字尺寸与菜单项一致 */
.up-side-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    padding: 2px 12px 12px;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
    font-size: 14px;
    color: var(--text-light);
}

.up-side-foot .nav-ico { font-size: 15px; width: 20px; text-align: center; }

.up-content { flex: 1; min-width: 0; }

.up-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.up-stat {
    background: rgba(255, 255, 255, .88);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow);
}

.up-stat-num { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.1; }

.up-stat-label { font-size: 12.5px; color: var(--text-light); }

.up-panel {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.up-panel h2 { font-size: 16px; margin-bottom: 14px; }

/* 面板头部：标题 + 右侧操作按钮 */
.up-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.up-panel-head h2 { margin-bottom: 0; }

/* 分类编辑框（点表格「编辑」后出现在面板顶部） */
.up-editcat-box {
    background: rgba(248, 250, 252, .92);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px 2px;
    margin-bottom: 16px;
}

/* 添加网址弹窗 */
.up-dialog {
    margin: auto; /* 抵消全局 * { margin: 0 }，保持弹窗居中 */
    border: none;
    border-radius: 14px;
    padding: 0;
    width: min(620px, calc(100vw - 40px));
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.up-dialog::backdrop { background: rgba(15, 23, 42, .45); }

.up-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
}

.up-dialog-head b { font-size: 15.5px; }

.up-dialog-close {
    border: none;
    background: #f1f5f9;
    color: #475569;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
}

.up-dialog-close:hover { background: #e2e8f0; }

.up-dialog-form {
    padding: 16px 20px 20px;
    max-height: min(68vh, 620px);
    overflow-y: auto;
}

/* 添加网址弹窗（上方图标库 + 底部单行表单） */
.up-dialog-lib {
    width: min(900px, calc(100vw - 40px));
    max-height: calc(100vh - 32px);
    overflow: hidden;
}

/* 仅打开时启用纵向弹性布局；关闭态保持 dialog 默认的 display:none，否则未点开也会显示 */
.up-dialog-lib[open] {
    display: flex;
    flex-direction: column;
}

.up-add-layout {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.up-add-lib {
    border-bottom: 1px solid rgba(15, 23, 42, .07);
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* 弹性占位：下方出现编辑行时自动压缩，图标网格内部滚动 */
    flex: 1 1 auto;
    min-height: 150px;
    max-height: min(420px, 52vh);
}

.up-lib-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.up-lib-tabs .chip { font-size: 12.5px; padding: 4px 12px; }

.up-lib-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
    align-content: start;
    padding: 2px;
}

.up-lib-item {
    position: relative;
    border: 1px solid transparent;
    background: none;
    border-radius: 10px;
    padding: 10px 4px 7px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
    transition: background .12s, border-color .12s;
}

.up-lib-item[hidden] { display: none; }

.up-lib-item:hover { background: #f1f5f9; }

.up-lib-item.picked { border-color: var(--primary); background: var(--primary-soft); }

.up-lib-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: #fff;
    border-radius: 9px;
    flex-shrink: 0;
}

.up-lib-name {
    font-size: 12px;
    color: var(--text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.up-lib-empty {
    font-size: 13px;
    color: var(--text-light);
    text-align: center;
    padding: 22px 10px;
    margin: 0;
}

/* 多选勾选角标（最多选 5 个） */
.up-lib-item .pick-badge {
    display: none;
    position: absolute;
    top: 4px;
    right: 6px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-style: normal;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(37, 99, 235, .35);
}

.up-lib-item .pick-badge::after { content: "✓"; }

.up-lib-item.picked .pick-badge { display: block; }

/* 已选编辑行：选中后在下方面板逐行填充，分类/名称/网址均可修改（最多 5 行，不滚动） */
.up-picked-rows {
    flex: none;
    margin: 0 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.up-picked-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-soft, #eff6ff);
    border: 1px solid #dbeafe;
    border-radius: 10px;
    padding: 6px 8px;
}

.up-picked-row img.p-ico,
.up-picked-row .p-noico {
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    flex: none;
}

.up-picked-row input,
.up-picked-row select {
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: #fff;
    border: 1px solid #dbeafe;
    border-radius: 7px;
    padding: 7px 9px;
    min-width: 0;
    outline: none;
    transition: border-color .15s;
}

.up-picked-row input:focus,
.up-picked-row select:focus { border-color: var(--primary); }

.up-picked-row .p-cat { flex: 0 1 170px; }

.up-picked-row .p-name { flex: 2 1 170px; }

.up-picked-row .p-url { flex: 2 1 220px; }

.up-picked-row .p-cat.p-err,
.up-picked-row .p-cat.p-err:focus { border-color: #f87171; }

.up-picked-row .p-del {
    flex: none;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #fecaca;
    color: #dc2626;
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.up-picked-row .p-del:hover { background: #fca5a5; }

/* 选择条：计数 + 清空 + 批量添加 */
.up-lib-selbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px 0;
    font-size: 13px;
    color: var(--text-light);
    flex: none;
}

.up-lib-selbar .sel-count b { color: var(--primary); font-size: 14px; }

.up-lib-selbar .sel-hint { color: #e05a5a; font-size: 12.5px; }

.up-lib-selbar .sel-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.up-lib-selbar button[disabled] { opacity: .55; cursor: not-allowed; }

.up-btn.up-btn-sm { padding: 7px 14px; font-size: 13.5px; flex: none; }

.up-dialog-lib .up-dialog-form { padding: 14px 20px 16px; }

/* 底部单行表单：分类 / 名称 / 网址 / 按钮横排，底边对齐 */
.up-add-row { align-items: flex-end; }

.up-add-row .up-btn { flex: none; }

.up-add-row .up-field-name { flex: 2 1 240px; }

.up-row { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 12px; }

.up-field { flex: 1 1 220px; min-width: 0; }

.up-field label {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.req { color: #ef4444; font-style: normal; }

.up-field input[type="text"],
.up-field select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
    transition: border .15s, box-shadow .15s;
}

.up-field input:focus, .up-field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.up-check { display: flex; align-items: flex-end; padding-bottom: 8px; }

/* 名称联想（图标对应库匹配下拉） */
.up-field { position: relative; }

.up-suggest {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .14);
    overflow: hidden;
}

.up-suggest-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: #fff;
    cursor: pointer;
    font-size: 13.5px;
    text-align: left;
    font-family: inherit;
    transition: background .12s;
}

.up-suggest-item:hover { background: #eff6ff; }

.up-suggest-item img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
    flex-shrink: 0;
}

.up-suggest-item .s-name { color: var(--text); font-weight: 600; white-space: nowrap; }
.up-suggest-item .s-url {
    color: var(--text-light);
    font-size: 12px;
    margin-left: auto;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.up-check label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
    margin: 0;
}

.up-btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 24px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}

.up-btn:hover { background: var(--primary-dark); }

.up-btn.gray { background: #f1f5f9; color: #475569; margin-left: 8px; }
.up-btn.gray:hover { background: #e2e8f0; }

.up-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.up-table th, .up-table td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.up-table th { color: var(--text-light); font-size: 12.5px; background: rgba(248, 250, 252, .85); }

.up-table tbody tr:hover { background: rgba(248, 250, 255, .8); }

/* 我的网址：分类横向一排标签，点击切换显示对应分类 */
.up-cat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.up-cat-tabs .chip { font-size: 13.5px; padding: 5px 16px; }

.up-cat-block { margin-bottom: 4px; }

.up-cat-title {
    display: flex;
    align-items: center;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
    padding: 4px 0 8px;
    margin: 0;
}

.up-cat-title::before {
    content: '';
    width: 4px;
    height: 14px;
    border-radius: 2px;
    background: var(--primary);
    margin-right: 8px;
}

.up-cat-empty { font-size: 13px; color: var(--text-light); padding: 2px 0 6px; }

.row-dim { opacity: .55; }

.up-link { color: var(--text); text-decoration: none; }
.up-link:hover { color: var(--primary); }

.up-url {
    display: block;
    color: #94a3b8;
    font-size: 12px;
    margin-top: 2px;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.up-badge {
    display: inline-block;
    font-size: 11.5px;
    border-radius: 5px;
    padding: 2px 8px;
    border: 1px solid transparent;
}

.up-badge.ok { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.up-badge.off { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }

.up-ops { white-space: nowrap; }
.up-ops .up-mini, .up-ops form { margin-right: 4px; }

.up-mini {
    display: inline-block;
    font-size: 12.5px;
    color: var(--primary);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 4px 10px;
    text-decoration: none;
    cursor: pointer;
    transition: all .15s;
}

.up-mini:hover { background: #dbeafe; }
.up-mini.gray { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.up-mini.gray:hover { background: #e2e8f0; }
.up-mini.danger { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.up-mini.danger:hover { background: #fee2e2; }

/* 上移/下移到边界时的禁用态（不可点的 span） */
.up-mini.up-mini-disabled {
    color: #cbd5e1;
    background: #f8fafc;
    border-color: #eef2f7;
    cursor: not-allowed;
    user-select: none;
}

.inline { display: inline-block; }

.up-alert {
    border-radius: 8px;
    padding: 11px 15px;
    font-size: 13.5px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}

.up-alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.up-alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.up-empty { color: var(--text-light); font-size: 13.5px; padding: 14px 4px; }

/* 图标库选择器（网址表单内） */
.icon-picker-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
    max-height: 240px;
    overflow-y: auto;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.ipick {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}

.ipick:hover { border-color: var(--primary); transform: translateY(-1px); }

.ipick.active {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .25);
}

.ipick img { width: 30px; height: 30px; object-fit: contain; }

.ipick-letter {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    user-select: none;
}

/* 图标库管理面板 */
.lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.lib-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.lib-card img { width: 34px; height: 34px; object-fit: contain; }

.lib-card .ipick-letter { width: 34px; height: 34px; font-size: 16px; }

.lib-del {
    position: absolute;
    top: 4px;
    right: 4px;
    line-height: 1;
}

.lib-del button {
    width: 19px;
    height: 19px;
    border: none;
    border-radius: 50%;
    background: rgba(220, 38, 38, .12);
    color: #dc2626;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    opacity: .3;
    transition: all .15s;
    padding: 0;
}

.lib-card:hover .lib-del button { opacity: 1; background: #dc2626; color: #fff; }

/* 文件选择框 */
.up-field input[type="file"] {
    width: 100%;
    font-size: 13.5px;
    color: var(--text);
    padding: 7px 0;
}

.up-field input[type="file"]::file-selector-button {
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
    border-radius: 7px;
    padding: 7px 14px;
    margin-right: 10px;
    cursor: pointer;
    font-size: 13px;
}

.up-field input[type="file"]::file-selector-button:hover { background: #dbeafe; }

/* ---------------- 登录 / 注册页 ---------------- */
.auth-body {
    background-color: #d3e1ea;
    background-image: none;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-box {
    width: 380px;
    max-width: 100%;
    background: #d3e1ea;
    border-radius: 14px;
    box-shadow: none;
    padding: 34px 32px 26px;
    text-align: center;
}

.auth-logo { font-size: 40px; margin-bottom: 18px; }

.auth-box h1 { font-size: 19px; margin-top: 6px; }

.auth-sub { color: var(--text-light); font-size: 13px; margin: 4px 0 18px; }

.auth-field { margin-bottom: 14px; text-align: left; }

.auth-field label {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.auth-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border .15s, box-shadow .15s;
}

.auth-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

/* 带图标的输入框（登录页） */
.auth-input-wrap { position: relative; }

.auth-input-wrap input {
    width: 100%;
    height: 46px;
    padding: 0 14px 0 44px;
    border: 1px solid #e3e6eb;
    border-radius: 10px;
    background: #fff;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border .15s, box-shadow .15s;
}

.auth-input-wrap input::placeholder { color: #b6bcc6; }

.auth-input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.auth-input-ico {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: #9aa3af;
    pointer-events: none;
}

/* 验证码行：输入框 + 获取验证码按钮 */
.auth-code-row {
    display: flex;
    gap: 10px;
}

.auth-code-row .auth-input-wrap {
    flex: 1;
    min-width: 0;
}

.auth-code-btn {
    flex: none;
    height: 46px;
    padding: 0 18px;
    border: 1px solid var(--primary);
    border-radius: 10px;
    background: #fff;
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}

.auth-code-btn:hover:not(:disabled) { background: var(--primary-soft); }
.auth-code-btn:disabled { opacity: .6; cursor: not-allowed; }

.auth-btn {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-size: 15px;
    cursor: pointer;
    transition: background .2s;
}

.auth-btn:hover { background: var(--primary-dark); }

.auth-alert {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13.5px;
    margin-bottom: 14px;
    text-align: left;
}

.auth-alt { margin-top: 16px; font-size: 12.5px; color: var(--text-light); }
.auth-alt a { color: var(--primary); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
    .grid { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 820px) {
    .grid { grid-template-columns: repeat(5, 1fr); }
    .logo { font-size: 22px; }
    .logo-ico { font-size: 26px; }
    body { background-attachment: scroll; }
}

@media (max-width: 860px) {
    .up-layout { flex-direction: column; }
    .up-side { width: 100%; position: static; }
    .up-side-nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .up-side-nav a { margin-bottom: 0; }
    .up-side-foot { display: none; }
}

@media (max-width: 620px) {
    .grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .site-card { padding: 10px 2px 8px; }
    .site-ico { width: 40px; height: 40px; border-radius: 10px; }
    .site-name { font-size: 12px; }
    .bar-inner { padding-top: 14px; padding-bottom: 14px; gap: 12px; }
    .search-row { flex-direction: column; gap: 12px; }
    .user-area { top: 10px; right: 12px; gap: 6px; }
    .user-avatar { width: 34px; height: 34px; font-size: 15px; }
    .clock-bar { flex-direction: column; align-items: center; gap: 12px; }
    /* 窄屏无需和天气卡片对齐，去掉 59px 固定高度，消除时间与日期之间的多余空隙 */
    .clock-time { font-size: 40px; height: auto; line-height: 1.15; }
    .clock-date { font-size: 13px; }
    .clock-date .dot { margin: 0 4px; }
    .weather-card { display: none; } /* 窄屏时间与天气上下堆叠，直接隐藏天气 */
}

/* ---------------- 登录/注册弹窗 ---------------- */
.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-modal[hidden] { display: none; }

.auth-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(3px);
}

.auth-modal-box {
    position: relative;
    width: min(440px, 94vw);
    background: #d3e1ea;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
    overflow: hidden;
}

.auth-modal-box iframe {
    display: block;
    width: 100%;
    border: 0;
}

.auth-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    color: #475569;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .18);
}

.auth-modal-close:hover { color: var(--primary); }

/* ---------------- 分页（个人后台网址列表） ---------------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination .pg-cur, .pagination .pg-dots {
    min-width: 32px;
    text-align: center;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    color: #4b5563;
    background: #f1f5f9;
    border: 1px solid #e5e7eb;
}
.pagination a:hover { color: var(--primary); border-color: #bfdbfe; background: #eff6ff; }
.pagination .pg-cur { color: #fff; background: var(--primary); border-color: var(--primary); font-weight: 600; }
.pagination .pg-dots { border: 0; background: none; }

/* ---------------- 在线客服（右下角悬浮，调色板下方） ---------------- */
.kf-switch {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 90;
}

.kf-fab {
    width: 46px;
    height: 46px;
    border: 1px solid var(--chip-border);
    border-radius: 50%;
    background: var(--chip-bg);
    box-shadow: var(--shadow);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all .2s;
}

.kf-fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.kf-panel {
    position: absolute;
    right: 0;
    bottom: 58px;
    width: 268px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(17, 24, 39, .18);
    padding: 14px;
}

.kf-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 10px; }

.kf-qr {
    display: block;
    width: 180px;
    height: auto;
    margin: 0 auto 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.kf-form-title { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }

.kf-row + .kf-row { margin-top: 8px; }

.kf-rows { display: flex; flex-direction: column; gap: 8px; }

.kf-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-soft);
    background: var(--hover-soft);
    border-radius: 8px;
    padding: 7px 10px;
}

.kf-label { flex-shrink: 0; color: var(--text-faint); font-size: 12px; }
.kf-val { flex: 1; word-break: break-all; }

.kf-copy {
    flex-shrink: 0;
    border: none;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    border-radius: 6px;
    padding: 3px 8px;
    cursor: pointer;
}

.kf-copy:hover { background: var(--primary); color: #fff; }
.kf-time .kf-val { color: var(--text-faint); }

.kf-form { display: flex; flex-direction: column; gap: 8px; }

.kf-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    resize: vertical;
    font-family: inherit;
}

.kf-input:focus { outline: none; border-color: var(--primary); }

.kf-send {
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    padding: 9px 0;
    font-size: 13.5px;
    cursor: pointer;
}

.kf-send:hover { background: var(--primary-dark); }
.kf-send:disabled { opacity: .6; cursor: default; }
.kf-tip { font-size: 12px; color: var(--text-faint); min-height: 16px; }
.kf-tip.ok { color: #16a34a; }
.kf-tip.err { color: #dc2626; }
