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

:root {
    --bg: #0a0a0f;
    --text: #e0e0e0;
    --text-muted: #666;
    --card-bg: #141419;
    --card-border: #1e1e26;
    --link-bg: #1a1a22;
    --link-border: #2a2a35;
    --switch-bg: #1e1e26;
    --switch-border: #333;
    --heading: #fff;
    --footer: #444;
}

body.light {
    --bg: #f5f5f7;
    --text: #333;
    --text-muted: #888;
    --card-bg: #fff;
    --card-border: #e0e0e0;
    --link-bg: #f0f0f3;
    --link-border: #ddd;
    --switch-bg: #e0e0e0;
    --switch-border: #ccc;
    --heading: #111;
    --footer: #999;
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 40px;
}

/* 搜索栏 */
.search-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 720px;
    margin: 60px auto 16px;
    padding: 12px 12px 12px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}

.search-bar:focus-within {
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15), 0 0 20px rgba(74, 222, 128, 0.08);
    transform: scale(1.01);
}

body.light .search-bar:focus-within {
    border-color: #166534;
    box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12), 0 0 20px rgba(22, 101, 52, 0.06);
}

.search-engine {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    cursor: pointer;
}

.se-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}

.se-label.active {
    color: var(--heading);
    background: var(--link-bg);
}

.se-divider {
    font-size: 0.9rem;
    color: var(--card-border);
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    color: var(--text);
    font-size: 1.05rem;
    min-width: 0;
    transition: color 0.2s;
}

.search-bar:focus-within .search-input {
    color: var(--heading);
}

.search-input::placeholder {
    color: var(--text-muted);
    transition: color 0.3s, transform 0.3s;
}

.search-bar:focus-within .search-input::placeholder {
    color: transparent;
    transform: translateX(8px);
}

/* 三列布局 */
.main-layout {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.quicklinks {
    width: 160px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ql-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.82rem;
    transition: border-color 0.2s;
}

.ql-item:hover {
    border-color: var(--text-muted);
    color: var(--heading);
}

.ql-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 40px 20px;
}

/* 侧边栏小部件 */
.widget {
    padding: 18px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
}

.widget-time {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
}

.widget-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.widget-weather {
    display: flex;
    align-items: center;
    gap: 12px;
}

.widget-temp {
    font-size: 2rem;
    font-weight: 700;
    color: var(--heading);
}

.widget-cond {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.widget-location {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 日历 */
.widget-calendar {
    padding: 16px 18px;
}

.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cal-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--heading);
}

.cal-nav {
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.75rem;
    transition: color 0.2s;
}

.cal-nav:hover {
    color: var(--heading);
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.cal-day {
    padding: 6px 0;
    font-size: 0.78rem;
    border-radius: 6px;
    color: var(--text);
}

.cal-day.cal-empty {
    color: transparent;
}

.cal-day.cal-today {
    background: #4ade80;
    color: #0a0a0f;
    font-weight: 700;
}

body.light .cal-day.cal-today {
    background: #166534;
    color: #fff;
}

/* 节假日 */
.widget-holiday {
    padding: 16px 18px;
}

.holiday-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--card-border);
}

.holiday-item:last-child {
    border-bottom: none;
}

.holiday-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.holiday-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--heading);
    text-align: right;
}

.holiday-countdown {
    font-size: 0.72rem;
    font-weight: 400;
    color: #4ade80;
    margin-left: 8px;
}

body.light .holiday-countdown {
    color: #166534;
}

.holiday-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0;
}

/* 健康状态 */
.widget-health {
    text-align: center;
}

.health-days {
    font-size: 1.1rem;
    font-weight: 700;
}

.health-days.uptime-ok {
    color: #4ade80;
}

.health-days.uptime-fail {
    color: #f87171;
}

.health-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.health-updated {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.node-uptime {
    margin-top: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.node-uptime.uptime-ok {
    color: #4ade80;
}

.node-uptime.uptime-fail {
    color: #f87171;
}

body.light .node-uptime.uptime-ok {
    color: #166534;
}

body.light .node-uptime.uptime-fail {
    color: #dc2626;
}

body.light .health-days.uptime-ok {
    color: #166534;
}

body.light .health-days.uptime-fail {
    color: #dc2626;
}

.top-bar h1 {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--heading);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 8px;
    font-size: 0.95rem;
}

.tagline {
    text-align: center;
    color: var(--text-muted);
    margin-top: 10px;
    margin-bottom: 32px;
    font-size: 0.95rem;
    letter-spacing: 4px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mode-label.active {
    color: var(--heading);
}

.switch {
    width: 44px;
    height: 24px;
    background: var(--switch-bg);
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--switch-border);
    transition: background 0.2s;
}

.switch-thumb {
    width: 18px;
    height: 18px;
    background: var(--heading);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left 0.2s;
}

.switch.on .switch-thumb {
    left: 22px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    background: var(--switch-bg);
    border: 1px solid var(--switch-border);
    transition: background 0.2s;
}

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

.theme-icon {
    font-size: 1rem;
}

.group {
    margin-bottom: 40px;
}

.group-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--card-border);
}

.nodes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.node-card {
    padding: 20px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    transition: background 0.3s, border-color 0.3s;
}

.node-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.node-icon {
    font-size: 1.4rem;
}

.node-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading);
}

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

.node-status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: auto;
    background: #333;
    transition: background 0.3s;
}

.node-status.online {
    background: #4ade80;
    box-shadow: 0 0 6px #4ade8066;
}

.node-status.offline {
    background: #f87171;
    box-shadow: 0 0 6px #f8717166;
}

.node-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.node-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.82rem;
    text-decoration: none;
    color: var(--text);
    background: var(--link-bg);
    border: 1px solid var(--link-border);
    transition: border-color 0.2s, color 0.2s, background 0.3s;
}

.node-link:hover {
    border-color: var(--text-muted);
    color: var(--heading);
}

.node-link .link-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-https {
    background: #1a3a2a;
    color: #4ade80;
}

.badge-http {
    background: #3a2a1a;
    color: #fbbf24;
}

.badge-lan {
    background: #1a2a3a;
    color: #60a5fa;
}

body.light .badge-https {
    background: #d1fae5;
    color: #166534;
}

body.light .badge-http {
    background: #fef3c7;
    color: #92400e;
}

body.light .badge-lan {
    background: #dbeafe;
    color: #1e40af;
}

.badge-rdp {
    background: #2a1a3a;
    color: #c084fc;
}

body.light .badge-rdp {
    background: #f3e8ff;
    color: #7c3aed;
}

footer {
    margin-top: 60px;
    text-align: center;
    color: var(--footer);
    font-size: 0.8rem;
}

.icp {
    margin-top: 4px;
}

/* 登录遮罩 */
#loginOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.login-bg {
    position: absolute;
    inset: 0;
    background: #0a0a0f;
}

.login-card {
    position: relative;
    width: 360px;
    max-width: 90vw;
    padding: 40px 32px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    text-align: center;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--heading);
    margin-bottom: 8px;
}

.login-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--text-muted);
}

.login-error {
    font-size: 0.82rem;
    color: #f87171;
    margin-top: 10px;
    min-height: 20px;
    opacity: 0;
    transition: opacity 0.2s;
}

.login-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #4ade80;
    color: #0a0a0f;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-btn:hover {
    opacity: 0.85;
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

body.light .login-bg {
    background: #f5f5f7;
}

body.light .login-btn {
    background: #166534;
    color: #fff;
}

.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* 入场动画 */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes blurIn {
    from { opacity: 0; filter: blur(8px); }
    to   { opacity: 1; filter: blur(0); }
}

/* 初始隐藏，等待触发 */
.anim-ready .top-bar          { opacity: 0; }
.anim-ready .search-bar       { opacity: 0; }
.anim-ready .tagline          { opacity: 0; }
.anim-ready .widget           { opacity: 0; }
.anim-ready .node-card        { opacity: 0; }
.anim-ready .ql-item          { opacity: 0; }

/* 触发后动画 */
.anim-go .top-bar             { animation: blurIn 0.5s ease-out both; }
.anim-go .search-bar          { animation: scaleIn 0.5s 0.1s ease-out both; }
.anim-go .tagline             { animation: fadeUp 0.5s 0.2s ease-out both; }
.anim-go .widget              { animation: fadeLeft 0.5s ease-out both; }
.anim-go .ql-item             { animation: fadeRight 0.4s ease-out both; }
.anim-go .node-card           { animation: fadeUp 0.5s ease-out both; }

/* 侧边栏组件级联 */
.anim-go .widget:nth-child(1) { animation-delay: 0.25s; }
.anim-go .widget:nth-child(2) { animation-delay: 0.3s;  }
.anim-go .widget:nth-child(3) { animation-delay: 0.35s; }
.anim-go .widget:nth-child(4) { animation-delay: 0.4s;  }
.anim-go .widget:nth-child(5) { animation-delay: 0.45s; }

/* 快捷链接级联 */
.anim-go .ql-item:nth-child(1) { animation-delay: 0.3s;  }
.anim-go .ql-item:nth-child(2) { animation-delay: 0.34s; }
.anim-go .ql-item:nth-child(3) { animation-delay: 0.38s; }
.anim-go .ql-item:nth-child(4) { animation-delay: 0.42s; }
.anim-go .ql-item:nth-child(5) { animation-delay: 0.46s; }
.anim-go .ql-item:nth-child(6) { animation-delay: 0.5s;  }
.anim-go .ql-item:nth-child(7) { animation-delay: 0.54s; }
.anim-go .ql-item:nth-child(8) { animation-delay: 0.58s; }

/* 卡片级联 — JS 动态设置 style 覆盖 */
.anim-go .node-card {
    animation-delay: var(--card-delay);
}

@media (max-width: 1200px) {
    .quicklinks {
        display: none;
    }
}

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

@media (max-width: 800px) {
    .container {
        padding: 40px 16px;
    }

    .top-bar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 24px 16px;
    }

    .top-bar h1 {
        font-size: 1.8rem;
    }

    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .widget-time {
        font-size: 1.8rem;
    }

    .nodes {
        grid-template-columns: 1fr;
    }

    .node-card {
        padding: 16px 18px;
    }

    .node-links {
        flex-direction: column;
    }

    .node-link {
        justify-content: center;
    }
}
