:root {
    --klk-primary: #2563eb;
    --klk-primary-hover: #1d4ed8;
    --klk-text-main: #111827;
    --klk-text-normal: #1f2937;
    --klk-text-muted: #6b7280;
    --klk-text-light: #9ca3af;
    --klk-border: #e5e7eb;
    --klk-bg: #f3f4f6;
    --klk-soft-bg: #f8fafc;
    --klk-white: #ffffff;
    --klk-danger: #ef4444;
    --klk-success: #16a34a;
    --klk-warning: #f59e0b;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--klk-text-normal);
    background: var(--klk-bg);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    vertical-align: middle;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    background: none;
    cursor: pointer;
}

.klk-container {
    width: 1180px;
    max-width: calc(100% - 32px);
    margin: 0 auto;
}

.klk-btn {
    height: 36px;
    padding: 0 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.klk-btn-primary {
    background: var(--klk-primary);
    color: var(--klk-white);
    border-color: var(--klk-primary);
}

.klk-btn-primary:hover {
    background: var(--klk-primary-hover);
    border-color: var(--klk-primary-hover);
}

.klk-btn:disabled,
.klk-btn.is-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.klk-btn-secondary {
    background: var(--klk-white);
    color: var(--klk-primary);
    border-color: #bfdbfe;
}

.klk-btn-secondary:hover {
    border-color: var(--klk-primary);
}

.klk-btn-block {
    width: 100%;
}

.klk-header {
    height: 56px;
    background: var(--klk-white);
    border-bottom: 1px solid var(--klk-border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.klk-header-inner {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
}

.klk-header-left,
.klk-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0;
}

.klk-header-left {
    flex: 0 0 auto;
}

.klk-header-right {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 12px;
}

.klk-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--klk-text-main);
    font-size: 20px;
    font-weight: 800;
    white-space: nowrap;
}

.klk-logo-mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: var(--klk-white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 900;
}

.klk-nav {
    display: flex;
    align-items: center;
    gap: 22px;
    color: #4b5563;
    font-size: 14px;
    white-space: nowrap;
}

.klk-nav a {
    position: relative;
}

.klk-nav a:hover,
.klk-nav a.is-active {
    color: var(--klk-primary);
}

.klk-nav a.is-hot::after,
.klk-nav a.is-new::after {
    position: absolute;
    left: 50%;
    top: -15px;
    transform: translateX(-50%);
    height: 14px;
    padding: 0 5px;
    border-radius: 8px 8px 8px 0;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 14px;
}

.klk-nav a.is-hot::after {
    content: "HOT";
    background: #ef4444;
}

.klk-nav a.is-new::after {
    content: "新";
    background: #f97316;
}

.klk-header-search {
    width: 320px;
    max-width: 100%;
    flex: 0 1 320px;
    height: 34px;
    display: flex;
    align-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #f8fafc;
    overflow: hidden;
}

.klk-header-search input {
    width: 100%;
    height: 32px;
    min-width: 0;
    padding: 0 10px;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--klk-text-normal);
    font-size: 13px;
}

.klk-header-search input::placeholder {
    color: #9ca3af;
}

.klk-header-search button {
    height: 32px;
    padding: 0 12px;
    color: #64748b;
    font-size: 13px;
    white-space: nowrap;
}

.klk-header-search:focus-within {
    border-color: #cbd5e1;
    background: #fff;
}

.klk-header-search button:hover {
    color: var(--klk-primary);
}

.klk-header-action {
    height: 34px;
    padding: 0 14px;
    border-radius: 4px;
    background: var(--klk-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.klk-header-action:hover {
    background: var(--klk-primary-hover);
}

.klk-login-group {
    height: 34px;
    padding: 0 12px;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    color: var(--klk-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.klk-login-group a:hover {
    color: var(--klk-primary-hover);
}

.klk-login-group span {
    color: #bfdbfe;
}

.klk-user-menu {
    position: relative;
    flex: 0 0 auto;
}

.klk-user-trigger {
    height: 36px;
    padding: 0 10px 0 6px;
    border: 0px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: var(--klk-text-normal);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
}

.klk-user-trigger:hover,
.klk-user-menu:focus-within .klk-user-trigger {
    border-color: #cbd5e1;
    color: var(--klk-primary);
}

.klk-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    object-fit: cover;
    display: block;
    flex: 0 0 auto;
}

.klk-user-name {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.klk-user-arrow {
    width: 7px;
    height: 7px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: .7;
}

.klk-user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 196px;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
    display: none;
    z-index: 50;
}

.klk-user-menu:hover .klk-user-dropdown,
.klk-user-menu:focus-within .klk-user-dropdown {
    display: block;
}

.klk-user-dropdown::before {
    content: "";
    position: absolute;
    right: 0;
    top: -9px;
    width: 100%;
    height: 9px;
}

.klk-user-dropdown a {
    min-height: 34px;
    padding: 0 8px;
    border-radius: 4px;
    color: var(--klk-text-normal);
    display: flex;
    align-items: center;
    font-size: 14px;
}

.klk-user-dropdown a:hover {
    background: #f8fafc;
    color: var(--klk-primary);
}

.klk-user-card {
    padding: 6px 6px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.klk-user-card .klk-user-avatar {
    width: 34px;
    height: 34px;
}

.klk-user-card-text {
    min-width: 0;
}

.klk-user-card-name {
    color: var(--klk-text-main);
    font-size: 14px;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.klk-user-card-note {
    color: var(--klk-text-muted);
    font-size: 12px;
    line-height: 18px;
}

.klk-user-divider {
    height: 1px;
    margin: 6px 0;
    background: #eef2f7;
}

.klk-user-dropdown .klk-user-logout {
    color: #dc2626;
}

.klk-user-dropdown .klk-user-logout:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.klk-footer {
    background: var(--klk-white);
    border-top: 1px solid var(--klk-border);
    padding: 28px 0;
    color: var(--klk-text-muted);
    font-size: 14px;
}

.klk-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.klk-footer-links {
    display: flex;
    align-items: center;
    gap: 18px;
}

.klk-footer-links a:hover {
    color: var(--klk-primary);
}

/*
 * 返回顶部按钮
 */
.klk-back-to-top {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 50;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--klk-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
    color: var(--klk-text-secondary);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease,
        background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

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

.klk-back-to-top:hover {
    border-color: var(--klk-primary);
    background: var(--klk-primary);
    color: var(--klk-white);
}

.klk-back-to-top:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 3px;
}

.klk-back-to-top svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 760px) {
    .klk-header {
        height: auto;
    }

    .klk-header-inner {
        height: auto;
        padding: 12px 0;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .klk-header-left,
    .klk-header-right {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }

    .klk-header-right {
        flex-wrap: wrap;
    }

    .klk-header-search {
        width: 100%;
        max-width: none;
        flex: 0 0 100%;
        order: -1;
    }

    .klk-nav {
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .klk-header-action {
        display: none;
    }

    .klk-user-menu {
        margin-left: auto;
    }

    .klk-user-dropdown {
        right: 0;
    }
    
    .klk-back-to-top {
        right: 16px;
        bottom: 18px;
        width: 42px;
        height: 42px;
    }
}
