/* ========== 基础重置与变量 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f0f1a;
    --card-bg: rgba(255, 255, 255, 0.06);
    --card-hover: rgba(255, 255, 255, 0.12);
    --text: #e8e8ed;
    --text2: #9ca3af;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --border: rgba(255, 255, 255, 0.08);
    --search-bg: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --modal-bg: #1a1a2e;
    --overlay-alpha: rgba(15, 15, 26, 0.7);
}

:root.light {
    --bg: #f0f2f5;
    --card-bg: rgba(0, 0, 0, 0.04);
    --card-hover: rgba(0, 0, 0, 0.08);
    --text: #1a1a2e;
    --text2: #6b7280;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --border: rgba(0, 0, 0, 0.08);
    --search-bg: rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --modal-bg: #ffffff;
    --overlay-alpha: rgba(240, 242, 245, 0.75);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.4s ease, color 0.4s ease;
}

/* ========== 无障碍辅助：仅屏幕阅读器可见 ========== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========== Bing 每日背景 ========== */
.bing-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1.2s ease;
    opacity: 0;
}

.bing-bg.loaded {
    opacity: 1;
}

/* 磨砂玻璃遮罩 */
.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, 
        var(--overlay-alpha) 0%, 
        color-mix(in srgb, var(--overlay-alpha) 90%, transparent) 40%, 
        var(--overlay-alpha) 100%
    );
    backdrop-filter: blur(2px);
}

/* 浅色模式下 overlay 使用更淡的遮罩 */
:root.light .bg-overlay {
    background: linear-gradient(135deg,
        rgba(240, 242, 245, 0.5) 0%,
        rgba(240, 242, 245, 0.4) 40%,
        rgba(240, 242, 245, 0.5) 100%
    );
    backdrop-filter: blur(4px);
}

/* Bing 版权 */
.bing-copyright {
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.8s;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ========== 容器 ========== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    position: relative;
    z-index: 1;
}

/* ========== 顶部左右分区 ========== */
.top-row {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 40px;
}

/* ========== Header 时间区域 ========== */
.header {
    flex: 0 0 66.66%;
    min-width: 0;
    padding: 0 0 0 40px;
}

.time {
    display: block;
    font-size: 72px;
    font-weight: 200;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #e8e8ed 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.date {
    font-size: 16px;
    color: var(--text2);
    margin-top: 8px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.greeting {
    font-size: 22px;
    margin-top: 10px;
    color: var(--text2);
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.user-name {
    font-size: 13px;
    color: rgba(255,255,255,0.25);
    margin-top: 4px;
}

/* ========== 位置和天气 ========== */
.location-weather {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 24px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.location-info,
.weather-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text2);
    transition: all 0.3s;
    cursor: pointer;
}

.weather-info:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(99, 102, 241, 0.4);
}

.location-info {
    cursor: pointer;
    position: relative;
}

.location-info:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(99, 102, 241, 0.4);
}

.loc-icon {
    width: 16px;
    height: 16px;
    color: var(--accent);
    flex-shrink: 0;
}

.loc-arrow {
    width: 14px;
    height: 14px;
    color: var(--text2);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.loc-text {
    color: var(--text);
}

.weather-icon { font-size: 18px; }
.weather-temp { color: var(--text); font-weight: 600; }
.weather-desc { color: var(--text2); }

/* ========== 城市选择弹窗 ========== */
.city-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.city-overlay.active { display: flex; }

.city-modal {
    background: var(--modal-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%;
    max-width: 480px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.city-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
}

.city-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.city-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--card-bg);
    color: var(--text2);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.city-close:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.city-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 24px 12px;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.city-search .search-icon { width: 18px; height: 18px; color: var(--text2); flex-shrink: 0; }

.city-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.city-search input::placeholder { color: var(--text2); }

.city-actions { padding: 0 24px 8px; }

.city-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    width: 100%;
}

.city-btn:hover { background: var(--card-hover); border-color: var(--accent); }
.city-btn-gps svg { color: var(--accent); }

.city-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 24px 20px;
}

.city-list::-webkit-scrollbar { width: 4px; }
.city-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.city-group-title {
    font-size: 12px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 0 8px;
    font-weight: 600;
}

.city-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
    font-size: 14px;
}

.city-item:hover { background: var(--card-hover); }
.city-item.active { background: rgba(99, 102, 241, 0.12); color: var(--accent); }
.city-item .city-name { font-weight: 500; }

.city-item .city-check {
    color: var(--accent);
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
}

.city-item.active .city-check { opacity: 1; }
.city-item.hidden { display: none; }
.loc-text.loading { color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.city-no-result { text-align: center; color: var(--text2); padding: 30px 0; font-size: 14px; }

/* ========== 每日一言 ========== */
.daily-quote {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    animation: quoteFadeIn 1s ease-out;
}

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

.quote-text {
    font-size: 16px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.78);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.7;
    max-width: 660px;
    text-align: center;
}

.quote-text::before,
.quote-text::after {
    content: '"';
    color: var(--accent);
    opacity: 0.7;
}

.quote-from {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ========== 搜索栏 ========== */
.search-box {
    flex: 0 0 33.33%;
    min-width: 280px;
    max-width: 420px;
    padding-right: 24px;
    display: flex;
    flex-direction: column;
}

.search-engine-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.search-engine-tabs .tab {
    padding: 6px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text2);
    transition: all 0.2s;
    user-select: none;
}

.search-engine-tabs .tab:hover { color: var(--text); }
.search-engine-tabs .tab.active { background: var(--accent); color: #fff; }

.search-input-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 6px 8px 6px 20px;
    transition: all 0.3s;
}

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

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text2);
    flex-shrink: 0;
}

.search-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 16px;
    padding: 10px 12px;
    font-family: inherit;
}

.search-input-wrapper input::placeholder { color: var(--text2); }

.search-input-wrapper button {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    font-weight: 500;
}

.search-input-wrapper button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ========== 导航区域 ========== */
.nav-section {
    margin-bottom: 36px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.section-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

.section-desc {
    font-size: 12px;
    font-weight: 400;
    color: var(--text2);
    margin-left: 4px;
}

/* 8列网格 */
.link-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

/* 栏目尺寸变体（通过后台 colSize 控制） */
.link-grid.col-sm { grid-template-columns: repeat(4, 1fr); }
.link-grid.col-md { grid-template-columns: repeat(6, 1fr); }
.link-grid.col-lg { grid-template-columns: repeat(8, 1fr); }

/* 紧凑型链接卡片 */
.link-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.link-card:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.link-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
                rgba(99, 102, 241, 0.06) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.link-card:hover::before { opacity: 1; }

/* 色彩圆点 */
.link-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* favicon 图标 */
.link-icon {
    flex-shrink: 0;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.link-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.link-card .link-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.link-card .link-desc {
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
}

/* 鼠标悬停显示描述 */
.link-card:hover .link-desc {
    display: block;
}

.link-card:hover .link-name {
    display: none;
}

/* ========== 天气详情弹窗 ========== */
.weather-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.weather-overlay.active { display: flex; }

.weather-modal {
    background: var(--modal-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.25s ease-out;
}

.weather-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
}

.weather-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.weather-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--card-bg);
    color: var(--text2);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.weather-close:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.weather-detail-body {
    padding: 0 24px 24px;
}

.weather-detail-loading {
    text-align: center;
    color: var(--text2);
    padding: 30px 0;
}

.weather-detail-main {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.weather-detail-icon {
    font-size: 48px;
    line-height: 1;
}

.weather-detail-temp {
    font-size: 42px;
    font-weight: 200;
    color: var(--text);
}

.weather-detail-desc {
    font-size: 16px;
    color: var(--text2);
    margin-left: 4px;
}

.weather-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.weather-detail-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.weather-detail-item .wd-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.weather-detail-item .wd-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

/* 城市名显示 */
.weather-detail-city {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 4px;
}

/* ========== 页脚 ========== */
.footer {
    text-align: center;
    padding: 40px 0 20px;
    color: var(--text2);
    font-size: 13px;
    position: relative;
}

.version-tag {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.2);
    margin-top: 4px;
}

.admin-link {
    position: absolute;
    right: 0;
    bottom: 20px;
    color: rgba(255,255,255,0.15);
    text-decoration: none;
    font-size: 16px;
    transition: color 0.2s;
}

.admin-link:hover { color: var(--accent); }

/* ========== 主题切换按钮 ========== */
.theme-toggle-single {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--search-bg);
    backdrop-filter: blur(10px);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}
.theme-toggle-single:hover {
    background: var(--card-hover);
    border-color: var(--accent);
    transform: scale(1.05);
}

/* ========== 浅色模式特定覆盖 ========== */
:root.light .time {
    background: linear-gradient(135deg, #1a1a2e 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

:root.light .link-card {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.06);
}

:root.light .link-card:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

:root.light .search-input-wrapper {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.08);
}

:root.light .search-engine-tabs {
    background: rgba(255, 255, 255, 0.6);
}

:root.light .search-engine-tabs .tab.active {
    background: var(--accent);
}

:root.light .location-info,
:root.light .weather-info {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text2);
}

:root.light .weather-info:hover,
:root.light .location-info:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(99, 102, 241, 0.4);
}

:root.light .quote-text {
    color: rgba(0, 0, 0, 0.68);
    text-shadow: none;
}

:root.light .quote-text::before,
:root.light .quote-text::after {
    color: var(--accent);
}

:root.light .quote-from {
    color: rgba(0, 0, 0, 0.38);
    text-shadow: none;
}

:root.light .bing-copyright {
    color: rgba(0, 0, 0, 0.4);
}

:root.light .section-title {
    color: var(--text);
    text-shadow: none;
}

:root.light .greeting,
:root.light .date {
    color: var(--text2);
    text-shadow: none;
}

:root.light .version-tag {
    color: rgba(0, 0, 0, 0.2);
}

:root.light .admin-link {
    color: rgba(0, 0, 0, 0.15);
}

:root.light .user-name {
    color: rgba(0, 0, 0, 0.25);
}

:root.light .city-overlay {
    background: rgba(0, 0, 0, 0.3);
}

:root.light .weather-overlay {
    background: rgba(0, 0, 0, 0.3);
}

/* ========== 响应式 ========== */
@media (max-width: 1300px) {
    .container { max-width: 1100px; }
    .link-grid { grid-template-columns: repeat(6, 1fr); }
    .link-grid.col-sm { grid-template-columns: repeat(4, 1fr); }
    .link-grid.col-md { grid-template-columns: repeat(6, 1fr); }
    .link-grid.col-lg { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 960px) {
    .container { padding: 30px 16px 40px; }
    .top-row { flex-direction: column; align-items: stretch; gap: 24px; margin-bottom: 30px; }
    .header { flex: 1 1 auto; padding: 0; text-align: center; }
    .search-box { flex: 1 1 auto; width: 100%; max-width: 480px; min-width: unset; align-self: center; padding-right: 0; }
    .location-weather { justify-content: center; }
    .daily-quote { align-items: center; }
    .quote-text { text-align: center; font-size: 14px; max-width: 520px; }
    .link-grid { grid-template-columns: repeat(4, 1fr); }
    .link-grid.col-sm, .link-grid.col-md, .link-grid.col-lg { grid-template-columns: repeat(4, 1fr); }
    .time { font-size: 48px; }
    .theme-toggle-single { top: 14px; right: 14px; width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
}

@media (max-width: 640px) {
    .top-row { gap: 18px; margin-bottom: 20px; }
    .link-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .link-grid.col-sm, .link-grid.col-md, .link-grid.col-lg { grid-template-columns: repeat(3, 1fr); }
    .link-card { padding: 7px 10px; gap: 6px; }
    .link-card .link-name { font-size: 12px; }
    .time { font-size: 40px; }
    .location-weather { gap: 10px; }
    .location-info, .weather-info { font-size: 12px; padding: 4px 10px; }
    .quote-text { font-size: 13px; max-width: 380px; }
    .quote-from { font-size: 12px; }
    .theme-toggle-single { top: 10px; right: 10px; width: 34px; height: 34px; font-size: 16px; border-radius: 8px; }
}

@media (max-width: 420px) {
    .link-grid { grid-template-columns: repeat(2, 1fr); }
    .link-grid.col-sm, .link-grid.col-md, .link-grid.col-lg { grid-template-columns: repeat(2, 1fr); }
    .container { padding: 16px 10px 30px; }
    .time { font-size: 32px; }
}
