/* 前台导航 - 深色紫蓝风格，贴近参考图 */
:root {
    --bg-deep: #0b0a18;
    --bg-panel: rgba(28, 24, 48, 0.72);
    --bg-card: rgba(32, 28, 55, 0.85);
    --border: rgba(140, 120, 220, 0.28);
    --text: #e8e6f5;
    --text-muted: #9a96b0;
    --accent: #8b6cff;
    --accent-2: #5b8cff;
    --accent-soft: rgba(139, 108, 255, 0.22);
    --radius-pill: 999px;
    --radius-card: 14px;
    --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(110, 70, 200, 0.35), transparent 55%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(60, 40, 140, 0.25), transparent 50%),
        radial-gradient(ellipse 50% 40% at 10% 60%, rgba(80, 50, 160, 0.18), transparent 45%);
    background-attachment: fixed;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.has-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

body.has-bg::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(8, 6, 20, 0.55);
    z-index: -1;
    pointer-events: none;
}

.page {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 12px 16px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.modal-open {
    overflow: hidden;
}

/* 顶栏 */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    margin-bottom: 28px;
    gap: 8px;
    position: relative;
    z-index: 5;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    position: relative;
    z-index: 6;
}

.topbar-right {
    width: 80px;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--accent-soft);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.greeting-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    min-width: 0;
}

.clock {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    color: var(--text);
}

.greeting {
    color: var(--text);
}

/* 品牌 */
.brand {
    text-align: center;
    margin-bottom: 22px;
}

.brand-title {
    font-size: clamp(28px, 7vw, 34px);
    font-weight: 700;
    letter-spacing: 0.04em;
    background: linear-gradient(120deg, #c4b5ff 0%, #8eb6ff 55%, #b8a0ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.25;
    margin-bottom: 8px;
}

.brand-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* 搜索 */
.search-box {
    display: flex;
    align-items: center;
    background: rgba(20, 16, 40, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px 4px 4px 14px;
    margin-bottom: 18px;
    box-shadow: 0 0 0 1px rgba(120, 100, 200, 0.08), 0 8px 24px rgba(0, 0, 0, 0.25);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: rgba(139, 108, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(139, 108, 255, 0.15);
}

.search-icon {
    color: var(--text-muted);
    display: flex;
    flex-shrink: 0;
    margin-right: 8px;
}

.search-icon svg {
    width: 18px;
    height: 18px;
}

.search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    padding: 10px 0;
}

.search-input::placeholder {
    color: #6e6a85;
}

.search-btn {
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, #8b6cff 0%, #5b8cff 100%);
    box-shadow: 0 4px 14px rgba(100, 90, 220, 0.35);
    transition: transform 0.15s, filter 0.15s;
}

.search-btn:active {
    transform: scale(0.97);
}

.search-btn:hover {
    filter: brightness(1.08);
}

/* 分类横向滚动 */
.cats-wrap {
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.cats {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 4px 2px 8px;
    cursor: grab;
    scrollbar-width: none;
}

.cats::-webkit-scrollbar {
    display: none;
}

.cats.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
    user-select: none;
}

.cat-item {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.cat-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.cat-item.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(139, 108, 255, 0.95), rgba(100, 120, 255, 0.9));
    box-shadow: 0 4px 12px rgba(100, 90, 220, 0.3);
}

.cat-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.cat-icon-fallback {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.cat-icon-fallback svg {
    width: 16px;
    height: 16px;
}

/* 链接网格 */
.links-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex: 1;
    align-content: start;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    background: var(--bg-card);
    border: 1px solid rgba(120, 100, 180, 0.18);
    border-radius: var(--radius-card);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s, border-color 0.2s, background 0.2s;
    min-height: 58px;
    backdrop-filter: blur(8px);
}

.link-card:hover {
    transform: translateY(-2px);
    border-color: rgba(139, 108, 255, 0.45);
    background: rgba(40, 34, 70, 0.9);
}

.link-card.hidden {
    display: none;
}

.link-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
}

.link-icon-fallback {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7a5cff, #4a7cff);
}

.link-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.empty-tip {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 40px 10px;
}

/* 页脚 */
.footer {
    margin-top: 28px;
    text-align: center;
    font-size: 12px;
    color: #6a6680;
}

/* 音乐浮层 */
.music-bar {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 50;
    display: none;
}

.music-bar.show {
    display: block;
}

.music-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(30, 26, 55, 0.92);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.music-toggle.playing {
    color: #b8a0ff;
    box-shadow: 0 0 16px rgba(139, 108, 255, 0.35);
}

.music-toggle svg {
    width: 20px;
    height: 20px;
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal[hidden] {
    display: none !important;
}

.modal.is-open {
    display: flex !important;
}

.modal-card {
    width: 100%;
    max-width: 420px;
    max-height: min(80vh, 640px);
    background: rgba(28, 24, 48, 0.96);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 16px 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-card-list {
    max-width: 440px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.modal-head h3 {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.modal-close:hover {
    color: #fff;
    background: var(--accent-soft);
}

.modal-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.modal-body {
    flex: 1;
    overflow: auto;
    font-size: 14px;
    color: var(--text);
    line-height: 1.65;
}

.pre-wrap {
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-foot {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

.btn-ok {
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #8b6cff 0%, #5b8cff 100%);
}

.list-scroll {
    overflow: auto;
    max-height: min(60vh, 480px);
    display: grid;
    gap: 8px;
}

.list-item {
    text-align: left;
    border: 1px solid rgba(120, 100, 180, 0.18);
    background: rgba(20, 16, 40, 0.75);
    border-radius: 12px;
    padding: 12px;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s;
}

.list-item:hover {
    border-color: rgba(139, 108, 255, 0.45);
    background: rgba(40, 34, 70, 0.9);
}

.list-item-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.list-item-time {
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 480px) {
    .page {
        padding: 10px 12px 36px;
    }

    .topbar {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .topbar-right {
        display: none;
    }

    .greeting-wrap {
        order: -1;
        width: 100%;
        justify-content: center;
        font-size: 14px;
    }

    .topbar-left {
        width: auto;
    }

    .brand-title {
        font-size: 26px;
    }

    .links-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .modal-card {
        max-width: 100%;
    }
}

@media (min-width: 768px) {
    .page {
        max-width: 760px;
        padding: 24px 24px 48px;
    }

    .topbar-left,
    .topbar-right {
        width: 88px;
    }

    .links-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 14px;
    }

    .brand-title {
        font-size: 36px;
    }

    .modal-card {
        max-width: 480px;
    }
}

@media (min-width: 1100px) {
    .page {
        max-width: 1040px;
        padding: 28px 28px 56px;
    }

    .links-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
}
