/* ==========================================================================
   首页 · 布局与核心组件
   ========================================================================== */

html[data-mode="dark"] {
    color-scheme: dark;
}

/* ---------- 顶栏 ---------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    -webkit-backdrop-filter: var(--backdrop, blur(18px));
    backdrop-filter: var(--backdrop, blur(18px));
    border-bottom: 1px solid var(--border);
}

.navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.nav-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 9px;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    color: var(--on-accent);
    display: grid;
    place-items: center;
    font-size: 16px;
    box-shadow: 0 4px 14px var(--glow);
}

.nav-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.2px;
    white-space: nowrap;
}

.nav-slogan {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-3);
    margin-left: 4px;
    white-space: nowrap;
}

.nav-version {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .4px;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    padding: 1px 7px;
    border-radius: var(--radius-pill);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.user-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
}

.role-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
    border: 1px solid transparent;
}

.role-admin {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(217, 58, 58, .2);
}

.role-vip {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: rgba(217, 119, 6, .22);
}

.role-user {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: rgba(22, 163, 74, .2);
}

/* 顶栏按钮 */
.btn-nav {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 11px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--dur) var(--ease);
}

.btn-nav i {
    font-size: 13px;
}

.btn-nav:hover {
    border-color: var(--accent-line);
    color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.btn-nav-blue {
    background: var(--surface);
    color: var(--text-2);
}

.btn-nav-blue:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-line);
}

.btn-nav-red {
    background: transparent;
    border-color: var(--border);
    color: var(--text-2);
}

.btn-nav-red:hover {
    background: var(--danger-soft);
    border-color: rgba(217, 58, 58, .3);
    color: var(--danger);
}

.btn-nav-msg {
    background: var(--accent);
    color: var(--on-accent) !important;
    border-color: transparent;
    box-shadow: 0 4px 14px var(--glow);
}

.btn-nav-msg:hover {
    background: var(--accent-2);
    color: var(--on-accent) !important;
    box-shadow: 0 6px 18px var(--glow);
}

/* 主题切换 */
.theme-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.theme-btn {
    padding: 5px 11px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
    transition: all var(--dur) var(--ease);
}

.theme-btn:hover:not(.active) {
    color: var(--text);
    background: var(--surface);
}

.theme-btn.active {
    color: var(--on-accent);
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-weight: 600;
    box-shadow: 0 2px 8px var(--glow);
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 14px;
    transition: all var(--dur) var(--ease);
}

.icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

/* ---------- 页面容器 ---------- */
.page-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.page-left {
    display: none;
}

.page-center {
    width: 100%;
    min-width: 0;
}

.main-content {
    padding: 30px 0 40px;
}

/* ---------- 顶部问候区 ---------- */
.welcome-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.welcome-title {
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.6px;
    color: var(--text);
}

.welcome-subtitle {
    font-size: 13.5px;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: -6px;
}

.trial-info {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid transparent;
}

.trial-unlimited {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: rgba(22, 163, 74, .2);
}

.trial-countdown {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: rgba(217, 119, 6, .22);
}

/* 会员提示条 */
.member-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-radius: var(--radius-m);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.member-icon {
    font-size: 16px;
    line-height: 1;
}

.member-status {
    font-size: 12.5px;
    color: var(--text-2);
}

.member-status b {
    color: var(--accent);
    font-size: 14px;
}

.member-status.member-vip {
    color: var(--warn);
}

.member-btn {
    margin-left: auto;
    height: 30px;
    padding: 0 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--accent-line);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 600;
    transition: all var(--dur) var(--ease);
}

.member-btn:hover {
    background: var(--accent);
    color: var(--on-accent);
    border-color: transparent;
    box-shadow: 0 4px 14px var(--glow);
}

/* ---------- 搜索 ---------- */
.search-wrap {
    display: flex;
    justify-content: center;
    margin: 2px 0 0;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 640px;
}

.search-box > .fa-search {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 15px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 48px;
    padding: 0 44px 0 46px;
    border-radius: var(--radius-m);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    box-shadow: var(--shadow-1);
    transition: all var(--dur) var(--ease);
}

.search-input::placeholder {
    color: var(--text-3);
}

.search-input:hover {
    border-color: var(--border-2);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow), var(--shadow-1);
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: none;
    place-items: center;
    border-radius: 50%;
    color: var(--text-3);
    font-size: 13px;
}

.search-clear:hover {
    color: var(--text);
    background: var(--surface-3);
}

.search-count {
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
    min-height: 18px;
    margin-top: 6px;
}

/* 搜索命中高亮 */
.tool-name mark,
.tool-desc mark {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 2px;
}

/* ---------- 分类 + 视图工具条 ---------- */
.welcome-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 4px 0 0;
}

.category-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--dur) var(--ease);
}

.cat-tab i {
    font-size: 12px;
    opacity: .9;
}

.cat-tab:hover {
    border-color: var(--accent-line);
    color: var(--accent);
}

.cat-tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: var(--on-accent);
    font-weight: 600;
    box-shadow: 0 4px 14px var(--glow);
}

.cat-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    font-size: 10.5px;
    line-height: 16px;
    text-align: center;
    background: var(--surface-3);
    color: var(--text-2);
}

.cat-tab.active .cat-count {
    background: rgba(255, 255, 255, .22);
    color: inherit;
}

.view-toggle,
.list-cols-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--surface);
}

.view-toggle button,
.list-cols-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-xs);
    color: var(--text-3);
    font-size: 12px;
    white-space: nowrap;
    transition: all var(--dur) var(--ease);
}

.view-toggle button:hover,
.list-cols-toggle button:hover {
    color: var(--text);
    background: var(--surface-2);
}

.view-toggle button.active,
.list-cols-toggle button.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* ---------- 工具卡片网格 ---------- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.tool-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 15px 15px 24px;
    border-radius: var(--radius-m);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.tool-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-line);
    box-shadow: var(--shadow-2);
}

.tool-card-header {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 10px;
    padding-right: 26px;
}

.tool-card-header > div:last-child {
    min-width: 0;
}

.tool-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-line);
}

.tool-name {
    font-size: 14.5px;
    font-weight: 650;
    line-height: 1.35;
    color: var(--text);
    word-break: break-word;
    overflow-wrap: break-word;
}

.tool-desc {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: auto 0 12px;
}

.tag {
    padding: 2px 7px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    color: var(--text-3);
    font-size: 11px;
    line-height: 1.5;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}

.tag:hover {
    background: var(--accent);
    color: var(--on-accent);
}

.tool-actions {
    display: flex;
    gap: 7px;
    align-items: stretch;
}

.tool-open-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    border-radius: var(--radius-s);
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-line);
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
    transition: all var(--dur) var(--ease);
}

.tool-open-btn:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: var(--on-accent);
    box-shadow: 0 4px 14px var(--glow);
}

.tool-share-btn {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 14px;
    transition: all var(--dur) var(--ease);
}

.tool-share-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

/* 收藏星标 */
.fav-btn {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-xs);
    color: var(--text-3);
    font-size: 13px;
    z-index: 2;
    transition: all var(--dur) var(--ease);
}

.fav-btn:hover {
    color: var(--gold);
    background: rgba(245, 179, 1, .12);
    transform: scale(1.08);
}

.fav-btn.faved {
    color: var(--gold);
}

/* 热度徽标 */
.heat-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}

/* 说明徽标 / 拖拽把手 */
.tip-badge {
    position: absolute;
    bottom: 6px;
    left: 13px;
    color: var(--text-3);
    font-size: 11px;
    opacity: .65;
    z-index: 2;
    transition: opacity var(--dur) var(--ease);
}

.tool-card:hover .tip-badge {
    opacity: 1;
    color: var(--accent);
}

.drag-handle {
    position: absolute;
    bottom: 5px;
    right: 12px;
    color: var(--text-3);
    font-size: 12px;
    opacity: .3;
    cursor: grab;
    z-index: 2;
    transition: opacity var(--dur) var(--ease);
}

.tool-card:hover .drag-handle {
    opacity: .8;
}

.drag-handle:active {
    cursor: grabbing;
}

.tool-card.dragging {
    opacity: .35;
    transform: scale(.97);
}

.tool-card.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--glow);
}

/* 批量选择 */
.batch-mode .tool-card {
    cursor: default;
}

.batch-check {
    position: absolute;
    top: 9px;
    left: 9px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-xs);
    border: 1.5px solid var(--border-2);
    background: var(--surface);
    color: var(--on-accent);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 3;
    cursor: pointer;
}

.batch-mode .batch-check {
    display: flex;
}

.batch-check.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.batch-mode .tool-card-header {
    padding-left: 22px;
}

/* 空状态 / 骨架屏 */
.no-tools {
    grid-column: 1 / -1;
    padding: 64px 20px;
    text-align: center;
    color: var(--text-3);
    font-size: 14px;
}

.skeleton-card {
    padding: 15px;
    border-radius: var(--radius-m);
    border: 1px solid var(--border);
    background: var(--surface);
}

.skeleton-card .sk-line {
    height: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 37%, var(--surface-3) 63%);
    background-size: 936px 100%;
    animation: tb-shimmer 1.4s ease infinite;
}

.skeleton-card .sk-line.short {
    width: 55%;
}

.skeleton-card .sk-line.icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    margin-bottom: 14px;
}

@keyframes tb-shimmer {
    0% {
        background-position: -468px 0;
    }

    100% {
        background-position: 468px 0;
    }
}

@keyframes tb-fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-card.fade-in {
    animation: tb-fade-up .35s var(--ease) both;
}

/* ---------- 列表视图 ---------- */
.tools-grid.list-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 18px;
}

.tools-grid.list-view.cols-1 {
    grid-template-columns: 1fr;
}

.tools-grid.list-view.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.tools-grid.list-view.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.tools-grid.list-view .tool-card {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    height: auto;
    min-height: unset;
    padding: 8px 11px;
    border-radius: var(--radius-s);
}

.tools-grid.list-view .tool-card:hover {
    transform: none;
    box-shadow: var(--shadow-2);
}

.tools-grid.list-view .tool-card-header {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    padding-right: 0;
    align-items: center;
}

.tools-grid.list-view .tool-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
    border-radius: 8px;
}

.tools-grid.list-view .tool-name {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.tools-grid.list-view .tool-desc {
    font-size: 11px;
    -webkit-line-clamp: 1;
    margin-top: 1px;
}

.tools-grid.list-view .heat-badge {
    font-size: 10px;
    padding: 0 5px;
    flex-shrink: 0;
}

.tools-grid.list-view .tool-tags {
    display: none;
}

.tools-grid.list-view .tool-actions {
    margin-left: auto;
    flex-shrink: 0;
}

.tools-grid.list-view .tool-open-btn {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
    flex: none;
}

.tools-grid.list-view .tool-share-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

.tools-grid.list-view .fav-btn {
    position: static;
    margin-left: 2px;
    flex-shrink: 0;
}

.tools-grid.list-view .batch-check {
    position: static;
    margin-right: 2px;
    flex-shrink: 0;
}

.tools-grid.list-view .tip-badge,
.tools-grid.list-view .drag-handle {
    display: none;
}

/* ---------- 回到顶部 ---------- */
.back-to-top {
    position: fixed;
    right: 26px;
    bottom: 26px;
    z-index: 900;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 15px;
    box-shadow: var(--shadow-2);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: all .25s var(--ease);
}

.back-to-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    color: var(--accent);
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

/* 顶栏按宽度逐级收纳 */
@media (max-width: 1180px) {
    .btn-nav .btn-label {
        display: none;
    }

    .btn-nav {
        padding: 0 9px;
    }

    .nav-slogan {
        display: none;
    }
}

@media (max-width: 1040px) {
    .user-info {
        display: none;
    }
}

@media (max-width: 940px) {
    #statBtn {
        display: none;
    }

    .nav-version {
        display: none;
    }
}

@media (max-width: 780px) {
    #batchBtn {
        display: none;
    }
    .nav-title {
        font-size: 15px;
    }

    .user-info {
        display: none;
    }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
    .page-wrapper {
        padding: 0 18px;
    }

    .nav-slogan {
        display: none;
    }
}

@media (max-width: 980px) {
    .navbar-inner {
        height: 58px;
        padding: 0 14px;
    }

    .nav-right {
        gap: 6px;
    }

    .btn-nav span,
    .btn-nav .btn-label {
        display: none;
    }

    .welcome-title {
        font-size: 23px;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    }
}

@media (max-width: 768px) {
    .nav-title {
        font-size: 15px;
    }

    .nav-version,
    .user-info {
        display: none;
    }

    .theme-switcher {
        padding: 2px;
    }

    .theme-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .btn-nav {
        padding: 0 8px;
        font-size: 12px;
    }

    .btn-nav i {
        font-size: 13px;
    }

    .page-wrapper {
        padding: 0 12px;
    }

    .main-content {
        padding: 20px 0 28px;
    }

    .category-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .cat-tab {
        flex-shrink: 0;
        height: 30px;
        padding: 0 10px;
        font-size: 12px;
    }

    .cat-count {
        display: none;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .tool-card {
        padding: 12px;
    }

    .tool-icon {
        width: 36px;
        height: 36px;
        font-size: 17px;
    }

    .tool-name {
        font-size: 13px;
        padding-right: 16px;
    }

    .tool-desc {
        -webkit-line-clamp: 2;
        font-size: 11px;
    }

    .tool-tags {
        display: none;
    }

    .tool-open-btn {
        height: 32px;
        font-size: 12px;
    }

    .tool-share-btn {
        width: 32px;
        height: 32px;
    }

    .search-box {
        max-width: 100%;
    }

    .search-input {
        height: 44px;
    }
}

@media (max-width: 480px) {
    .tools-grid {
        grid-template-columns: 1fr 1fr;
    }

    .welcome-title {
        font-size: 20px;
    }

    .welcome-subtitle {
        font-size: 12.5px;
    }

    .member-btn {
        margin-left: 0;
    }

    .theme-switcher .theme-btn {
        padding: 4px 7px;
        font-size: 10.5px;
    }
}
