/* ==================== CSS变量 - 主题系统 ==================== */
:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fa;
    --bg-input: #ffffff;
    --bg-dropdown: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-tertiary: #a0aec0;
    --text-inverse: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #edf2f7;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
    --accent: #4A6CF7;
    --accent-hover: #3651d5;
    --accent-light: #eef1ff;
    --danger: #e53e3e;
    --danger-hover: #c53030;
    --success: #38a169;
    --warning: #d69e2e;
    --info: #3182ce;
    --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    --clock-color: #1a1a2e;
    --search-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --tag-bg: #ffffff;
    --tag-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --tag-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    --tag-hover-transform: translateY(-4px);
}

[data-theme="dark"] {
    --bg-primary: #0f1119;
    --bg-secondary: #1a1d28;
    --bg-tertiary: #22263a;
    --bg-card: #1e2130;
    --bg-card-hover: #262a3b;
    --bg-input: #1e2130;
    --bg-dropdown: #1e2130;
    --bg-overlay: rgba(0, 0, 0, 0.75);
    --bg-sidebar: #0d0f17;
    --bg-sidebar-hover: #1a1d28;
    --text-primary: #e8eaed;
    --text-secondary: #b0b5c0;
    --text-tertiary: #6b7280;
    --text-inverse: #0f1119;
    --border-color: #2d3148;
    --border-light: #252940;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.55);
    --accent: #6b8aff;
    --accent-hover: #8aa4ff;
    --accent-light: #1a2350;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --success: #4ade80;
    --warning: #fbbf24;
    --info: #60a5fa;
    --gradient-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --gradient-dark: linear-gradient(135deg, #0a0a15 0%, #0d1117 50%, #0a1628 100%);
    --clock-color: #e8eaed;
    --search-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --tag-bg: #1e2130;
    --tag-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    --tag-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    --tag-hover-transform: translateY(-4px);
}

/* ==================== 全局基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.4s ease, color 0.4s ease;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-hover);
}

/* ==================== 主题切换按钮 ==================== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-lg);
}
.theme-toggle:active {
    transform: scale(0.94);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    transition: all 0.4s ease;
    position: absolute;
}
[data-theme="dark"] .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}
[data-theme="dark"] .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}
[data-theme="light"] .theme-toggle .icon-sun,
:root .theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}
[data-theme="light"] .theme-toggle .icon-moon,
:root .theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}
.theme-toggle svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: var(--text-primary);
    stroke-width: 2;
}

/* ==================== 前台 - 标签页主界面 ==================== */
.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    background: var(--bg-primary);
    transition: background 0.4s ease;
}
.main-container.has-bg-image {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
}
.main-container.has-bg-image::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 0;
    transition: background 0.4s ease;
}
.main-container.has-bg-image > * {
    position: relative;
    z-index: 1;
}

.clock-section {
    text-align: center;
    margin-bottom: 20px;
}
.clock-time {
    font-size: clamp(48px, 8vw, 80px);
    font-weight: 300;
    letter-spacing: -2px;
    color: var(--clock-color);
    font-family: var(--font-sans);
    line-height: 1;
    transition: color 0.4s ease;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .clock-time {
    text-shadow: 0 2px 20px rgba(255, 255, 255, 0.06);
}
.clock-date {
    font-size: 18px;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 400;
    letter-spacing: 1px;
    transition: color 0.4s ease;
}

.search-section {
    width: 100%;
    max-width: 600px;
    margin-bottom: 40px;
    position: relative;
}
.search-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 50px;
    padding: 6px 8px 6px 20px;
    box-shadow: var(--search-shadow);
    transition: all var(--transition);
}
.search-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-light);
}
.search-engine-icon {
    font-size: 20px;
    margin-right: 10px;
    flex-shrink: 0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    user-select: none;
}
.search-engine-icon:hover {
    background: var(--bg-tertiary);
}
.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    padding: 8px 0;
    min-width: 0;
}
.search-input::placeholder {
    color: var(--text-tertiary);
}
.search-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 10px 22px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.search-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.03);
}
.search-engines-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 10px;
    margin-top: 8px;
    background: var(--bg-dropdown);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 180px;
    overflow: hidden;
    animation: fadeInDown 0.2s ease;
}
.search-engines-dropdown.active {
    display: block;
}
.search-engines-dropdown .engine-option {
    padding: 12px 18px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}
.search-engines-dropdown .engine-option:last-child {
    border-bottom: none;
}
.search-engines-dropdown .engine-option:hover {
    background: var(--bg-tertiary);
}
.search-engines-dropdown .engine-option.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 标签卡片网格 ==================== */
.tags-section {
    width: 100%;
    max-width: 900px;
}
.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    padding: 0 10px;
}
.tag-card {
    background: var(--tag-bg);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--tag-shadow);
    transition: all var(--transition);
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.tag-card:hover {
    box-shadow: var(--tag-hover-shadow);
    transform: var(--tag-hover-transform);
    border-color: var(--border-color);
}
.tag-card:active {
    transform: scale(0.95);
}
.tag-card .tag-color-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transition: height 0.3s ease;
}
.tag-card:hover .tag-color-bar {
    height: 6px;
}
.tag-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    overflow: hidden;
    transition: transform var(--transition);
}
.tag-card:hover .tag-icon {
    transform: scale(1.1);
}
.tag-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.tag-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    word-break: break-word;
    transition: color var(--transition);
}
.tag-card:hover .tag-title {
    color: var(--accent);
}
.no-tags {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px;
    font-size: 15px;
}

/* ==================== 用户菜单 ==================== */
.user-menu {
    position: fixed;
    top: 20px;
    right: 80px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-menu .btn {
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
}
.btn-login {
    background: var(--accent);
    color: #fff;
}
.btn-login:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}
.btn-register {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-color) !important;
}
.btn-register:hover {
    border-color: var(--accent) !important;
    color: var(--accent);
}
.btn-user-center {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-color) !important;
    border-radius: var(--radius-full) !important;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    justify-content: center;
    font-size: 18px;
}
.btn-user-center:hover {
    border-color: var(--accent) !important;
}
.btn-logout {
    background: transparent;
    color: var(--text-secondary);
    border: none !important;
    font-size: 13px;
    cursor: pointer;
}
.btn-logout:hover {
    color: var(--danger);
}
.user-greeting {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== 会员中心 & 后台布局 ==================== */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}
.dashboard-sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    color: #fff;
    padding: 30px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: background 0.4s ease;
}
.dashboard-sidebar .logo {
    padding: 0 24px 20px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}
.dashboard-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all var(--transition);
    font-size: 15px;
    border-left: 3px solid transparent;
}
.dashboard-sidebar .nav-item:hover,
.dashboard-sidebar .nav-item.active {
    background: var(--bg-sidebar-hover);
    color: #fff;
    border-left-color: var(--accent);
}
.dashboard-main {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    background: var(--bg-primary);
    transition: background 0.4s ease;
}
.dashboard-main h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: -0.5px;
}
.dashboard-main h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 20px 0 16px;
}

/* ==================== 卡片 & 表格 ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 20px;
    transition: all 0.4s ease;
}
.card-header {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    border-radius: 4px 4px 0 0;
}
table tr:hover td {
    background: var(--bg-card-hover);
}
table td {
    color: var(--text-primary);
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}
.form-input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: var(--font-sans);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: all var(--transition);
    outline: none;
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
select.form-input {
    cursor: pointer;
    appearance: auto;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    font-family: var(--font-sans);
    text-decoration: none;
    letter-spacing: 0.3px;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: var(--danger-hover);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}
.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}
.alert-error {
    background: #fed7d7;
    color: #822727;
    border: 1px solid #feb2b2;
}
[data-theme="dark"] .alert-success {
    background: #1a3c2a;
    color: #68d391;
    border-color: #2f6b46;
}
[data-theme="dark"] .alert-error {
    background: #3b1a1a;
    color: #fc8181;
    border-color: #6b2f2f;
}

/* ==================== 登录/注册页面 ==================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg-primary);
}
.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
    transition: all 0.4s ease;
}
.auth-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 26px;
    letter-spacing: -0.5px;
}
.auth-card .subtitle {
    text-align: center;
    color: var(--text-tertiary);
    margin-bottom: 28px;
    font-size: 14px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .dashboard-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 14px 10px;
        gap: 6px;
        justify-content: center;
    }
    .dashboard-sidebar .logo {
        display: none;
    }
    .dashboard-sidebar .nav-item {
        padding: 8px 14px;
        font-size: 13px;
        border-left: none;
        border-radius: 50px;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    .dashboard-sidebar .nav-item.active {
        border-left: none;
        background: var(--accent);
        border-color: var(--accent);
    }
    .dashboard-main {
        padding: 20px;
    }
    .tags-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    .tag-card {
        padding: 14px 10px;
    }
    .tag-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .tag-title {
        font-size: 12px;
    }
    .user-menu {
        right: 70px;
        gap: 6px;
        top: 16px;
    }
    .user-menu .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .theme-toggle {
        top: 14px;
        right: 14px;
        width: 38px;
        height: 38px;
        font-size: 17px;
    }
    .search-section {
        max-width: 95%;
    }
    .clock-time {
        font-size: clamp(36px, 10vw, 56px);
    }
}

@media (max-width: 480px) {
    .tags-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .tag-card {
        padding: 10px 6px;
        border-radius: var(--radius-md);
    }
    .tag-icon {
        width: 30px;
        height: 30px;
        font-size: 15px;
        border-radius: var(--radius-sm);
    }
    .tag-title {
        font-size: 11px;
    }
    .search-wrapper {
        padding: 4px 6px 4px 14px;
    }
    .search-input {
        font-size: 14px;
    }
    .search-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
}