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

:root {
    --bg-primary: #1a1d23;
    --bg-secondary: #21252b;
    --bg-card: #282c34;
    --bg-card-hover: #313640;
    --bg-input: #2c3038;
    --text-primary: #e0e0e0;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #4f8ef7;
    --accent-hover: #3b7de6;
    --border: #353b47;
    --border-light: #2d333d;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
}

[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f7fa;
    --bg-input: #f0f2f5;
    --text-primary: #1a1d23;
    --text-secondary: #555;
    --text-muted: #999;
    --accent: #4f8ef7;
    --accent-hover: #3b7de6;
    --border: #e0e4e8;
    --border-light: #e8ecf0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: light) {
    [data-theme="auto"], :root:not([data-theme]) {
        --bg-primary: #f0f2f5;
        --bg-secondary: #ffffff;
        --bg-card: #ffffff;
        --bg-card-hover: #f5f7fa;
        --bg-input: #f0f2f5;
        --text-primary: #1a1d23;
        --text-secondary: #555;
        --text-muted: #999;
        --accent: #4f8ef7;
        --accent-hover: #3b7de6;
        --border: #e0e4e8;
        --border-light: #e8ecf0;
        --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

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

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Content Wrapper - Two Column Layout */
.content-wrapper {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.content-main {
    flex: 1;
    min-width: 0;
    padding-top: 0;
}

.content-sidebar {
    width: 300px;
    flex-shrink: 0;
    position: sticky;
    top: 72px;
    padding: 20px 0;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    flex-shrink: 0;
    margin-left: 8px;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-icon {
    line-height: 1;
    display: none;
}

[data-theme="dark"] .theme-icon-light { display: inline; }
[data-theme="light"] .theme-icon-dark { display: inline; }

/* Search Section */
.search-section {
    padding: 48px 20px 32px;
    text-align: center;
}

.search-container {
    max-width: 640px;
    margin: 0 auto;
}

.search-form {
    margin-bottom: 20px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 28px;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.15);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 14px 20px;
    font-size: 1rem;
    color: var(--text-primary);
}

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

.search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    margin: 4px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}

.search-btn:hover {
    background: var(--accent-hover);
}

/* Engine Tabs */
.engine-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.engine-tab {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.engine-tab:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.engine-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Category Nav */
.category-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
}

.category-nav-container {
    max-width: 1280px;
    margin: 0 auto;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.category-link {
    padding: 7px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    transition: all var(--transition);
}

.category-link:hover {
    background: var(--accent);
    color: #fff;
}

/* Sites Section */
.sites-section {
    padding: 32px 0 48px;
}

.category-block {
    margin-bottom: 36px;
    scroll-margin-top: 120px;
}

.category-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.category-icon {
    color: var(--accent);
    font-size: 0.75rem;
}

/* Site Grid */
.site-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.site-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    text-align: center;
    transition: all var(--transition);
    min-height: 48px;
}

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

.site-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Sidebar Widgets */
.sidebar-widget {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.widget-header {
    margin-bottom: 14px;
}

.widget-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.widget-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

/* Calendar Widget */
.calendar-today {
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    margin-top: 10px;
}

.today-solar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.today-day {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.today-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.today-month {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.today-weekday {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.today-lunar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.festival-tag {
    background: #c0392b;
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
}

.term-tag {
    background: #27ae60;
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
}

/* Calendar Yiji */
.calendar-yiji {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.yiji-section {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    line-height: 1.5;
}

.yiji-label {
    flex-shrink: 0;
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.72rem;
    min-width: 28px;
    text-align: center;
}

.yiji-yi .yiji-label {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.yiji-ji .yiji-label {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.yiji-items {
    color: var(--text-secondary);
}

/* Mobile Calendar Button */
.category-link-mobile-calendar {
    display: none;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-align: center;
    white-space: nowrap;
    transition: all var(--transition);
    margin-top: 6px;
}

.category-link-mobile-calendar:hover {
    background: var(--accent-hover);
}

/* Calendar Month Navigation */
.calendar-month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.cal-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 700;
    transition: all var(--transition);
    line-height: 1;
    flex-shrink: 0;
}

.cal-nav-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
}

.cal-nav-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 90px;
    text-align: center;
    flex-shrink: 0;
}

.cal-nav-today {
    padding: 2px 8px;
    font-size: 0.72rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 10px;
    transition: all var(--transition);
    margin-left: 6px;
    flex-shrink: 0;
}

.cal-nav-today:hover {
    background: var(--accent);
    color: #fff;
}

/* Calendar Select */
.cal-select-form {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.cal-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.78rem;
    padding: 2px 4px;
    cursor: pointer;
    outline: none;
    text-align: center;
}

.cal-select:focus {
    border-color: var(--accent);
}

.cal-select-year {
    width: 58px;
}

.cal-select-month {
    width: 46px;
}

/* Calendar Holiday Cells */
.cal-holiday .cal-solar {
    color: #e74c3c;
    font-weight: 700;
}

.cal-holiday .cal-lunar {
    color: #e74c3c;
    font-weight: 600;
}

.cal-workday .cal-solar {
    color: #f39c12;
    font-weight: 600;
}

.cal-workday .cal-lunar {
    color: #f39c12;
}

/* Calendar Legend */
.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 8px;
    font-size: 0.72rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-holiday {
    background: #e74c3c;
}

.legend-workday {
    background: #f39c12;
}

/* Daily Quote */
.calendar-quote {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
}

.quote-label {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 6px;
}

.quote-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 4px;
}

.quote-author {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
}

.calendar-month-label {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.calendar-grid {
    font-size: 0.78rem;
}

.cal-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.cal-weekday {
    text-align: center;
    padding: 4px 0;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.72rem;
}

.cal-cell {
    text-align: center;
    padding: 3px 0 4px;
    border-radius: 4px;
    transition: all var(--transition);
    min-height: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cal-cell:hover {
    background: var(--bg-card-hover);
}

.cal-empty {
    background: transparent;
}

.cal-today {
    background: rgba(79, 142, 247, 0.2) !important;
    border-radius: 6px;
}

.cal-solar {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
}

.cal-today .cal-solar {
    color: var(--accent);
    font-weight: 700;
}

.cal-lunar {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.cal-special {
    color: #e74c3c !important;
    font-weight: 500;
}

.cal-weekend .cal-solar {
    color: #e74c3c;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 40px 0 24px;
    margin-top: 20px;
}

.footer-content {
    text-align: center;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

.footer-logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
}

.footer-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
}

.footer-links a {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color var(--transition);
}

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

.footer-copy {
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.footer-copy p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--transition);
    z-index: 50;
    pointer-events: none;
}

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

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

/* About Page */
.about-section {
    padding: 48px 20px;
    text-align: center;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.about-section h1 {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.about-section p {
    color: var(--text-secondary);
    max-width: 500px;
}

/* Responsive */
@media (max-width: 1200px) {
    .content-sidebar {
        width: 260px;
    }

    .site-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .content-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
    }

    .content-sidebar {
        width: 100%;
        max-width: 100%;
        position: static;
        max-height: none;
        padding: 0 20px 20px;
    }

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

    .site-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .search-section {
        padding-left: 0;
        padding-right: 0;
    }

    .category-nav {
        padding-left: 0;
        padding-right: 0;
    }

    .category-nav-container {
        padding: 0;
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 0;
        gap: 4px;
        justify-content: space-between;
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
        order: 1;
        width: 100%;
    }

    .nav-links a {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    .theme-toggle {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
        margin-left: 0;
    }

    .search-section {
        padding: 28px 0 24px;
    }

    .search-container {
        padding: 0 16px;
    }

    .content-sidebar {
        padding: 0 16px 16px;
    }

    .content-main {
        padding: 0 16px;
    }

    .site-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .site-card {
        padding: 10px 6px;
        min-height: 40px;
    }

    .site-name {
        font-size: 0.82rem;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    .category-link {
        font-size: 0.78rem;
        padding: 5px 8px;
    }

    .category-link-mobile-calendar {
        display: block;
    }

    .footer {
        padding: 32px 0 20px;
    }

    .footer-links {
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .site-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-input {
        padding: 12px 14px;
    }

    .search-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .engine-tab {
        padding: 4px 12px;
        font-size: 0.78rem;
    }

    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }
}
