:root {
    color-scheme: light;
    --page-scale: .8;
    --bg: #f4f8ff;
    --panel: rgba(255, 255, 255, .9);
    --panel-solid: #fff;
    --text: #13244a;
    --muted: #667799;
    --line: #d7e3f7;
    --blue: #0b7cff;
    --blue-2: #2f97ff;
    --shadow: 0 14px 40px rgba(29, 84, 160, .14);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    font-family: "Microsoft YaHei", Arial, sans-serif;
    background: var(--bg) url("assets/bg-light.jpg") center bottom / 100% auto no-repeat fixed;
}

body.theme-dark {
    color-scheme: dark;
    --bg: #081327;
    --panel: rgba(9, 25, 52, .88);
    --panel-solid: #0b1a36;
    --text: #edf5ff;
    --muted: #9fb0d0;
    --line: rgba(109, 154, 220, .25);
    --shadow: 0 20px 45px rgba(0, 0, 0, .26);
    background-image: url("assets/bg-dark.jpg");
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.page-shell {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(24px, 6vw, 110px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .56);
    backdrop-filter: blur(12px);
}
.theme-dark .topbar { background: rgba(8, 19, 39, .72); }

.brand-small {
    display: flex;
    align-items: center;
    gap: 0;
}
.brand-small strong {
    display: block;
    font-size: 24px;
    line-height: 1;
    color: #0b66db;
}
.theme-dark .brand-small strong { color: #79b6ff; }
.brand-small em {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-style: normal;
    font-size: 14px;
}

.quick-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch #themeSwitch {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2196f3;
    transition: 0.4s;
    z-index: 0;
    overflow: hidden;
}

.sun-moon {
    position: absolute;
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: yellow;
    transition: 0.4s;
}

#themeSwitch:checked + .slider {
    background-color: black;
}

#themeSwitch:focus + .slider {
    box-shadow: 0 0 1px #2196f3;
}

#themeSwitch:checked + .slider .sun-moon {
    transform: translateX(26px);
    background-color: white;
    animation: rotate-center 0.6s ease-in-out both;
}

.moon-dot {
    opacity: 0;
    transition: 0.4s;
    fill: gray;
}

#themeSwitch:checked + .slider .sun-moon .moon-dot {
    opacity: 1;
}

.slider.round {
    border-radius: 34px;
}

.slider.round .sun-moon {
    border-radius: 50%;
}

#moon-dot-1 {
    left: 10px;
    top: 3px;
    position: absolute;
    width: 6px;
    height: 6px;
    z-index: 4;
}

#moon-dot-2 {
    left: 2px;
    top: 10px;
    position: absolute;
    width: 10px;
    height: 10px;
    z-index: 4;
}

#moon-dot-3 {
    left: 16px;
    top: 18px;
    position: absolute;
    width: 3px;
    height: 3px;
    z-index: 4;
}

#light-ray-1 {
    left: -8px;
    top: -8px;
    position: absolute;
    width: 43px;
    height: 43px;
    z-index: -1;
    fill: white;
    opacity: 10%;
}

#light-ray-2 {
    left: -50%;
    top: -50%;
    position: absolute;
    width: 55px;
    height: 55px;
    z-index: -1;
    fill: white;
    opacity: 10%;
}

#light-ray-3 {
    left: -18px;
    top: -18px;
    position: absolute;
    width: 60px;
    height: 60px;
    z-index: -1;
    fill: white;
    opacity: 10%;
}

.cloud-light {
    position: absolute;
    fill: #eee;
    animation-name: cloud-move;
    animation-duration: 6s;
    animation-iteration-count: infinite;
}

.cloud-dark {
    position: absolute;
    fill: #ccc;
    animation-name: cloud-move;
    animation-duration: 6s;
    animation-iteration-count: infinite;
    animation-delay: 1s;
}

#cloud-1 {
    left: 30px;
    top: 15px;
    width: 40px;
}

#cloud-2 {
    left: 44px;
    top: 10px;
    width: 20px;
}

#cloud-3 {
    left: 18px;
    top: 24px;
    width: 30px;
}

#cloud-4 {
    left: 36px;
    top: 18px;
    width: 40px;
}

#cloud-5 {
    left: 48px;
    top: 14px;
    width: 20px;
}

#cloud-6 {
    left: 22px;
    top: 26px;
    width: 30px;
}

@keyframes cloud-move {
    0% { transform: translateX(0px); }
    40% { transform: translateX(4px); }
    80% { transform: translateX(-4px); }
    100% { transform: translateX(0px); }
}

@keyframes rotate-center {
    0% { transform: translateX(26px) rotate(0); }
    100% { transform: translateX(26px) rotate(360deg); }
}

.stars {
    transform: translateY(-32px);
    opacity: 0;
    transition: 0.4s;
}

.star {
    fill: white;
    position: absolute;
    transition: 0.4s;
    animation-name: star-twinkle;
    animation-duration: 2s;
    animation-iteration-count: infinite;
}

#themeSwitch:checked + .slider .stars {
    transform: translateY(0);
    opacity: 1;
}

#star-1 {
    width: 20px;
    top: 2px;
    left: 3px;
    animation-delay: 0.3s;
}

#star-2 {
    width: 6px;
    top: 16px;
    left: 3px;
}

#star-3 {
    width: 12px;
    top: 20px;
    left: 10px;
    animation-delay: 0.6s;
}

#star-4 {
    width: 18px;
    top: 0px;
    left: 18px;
    animation-delay: 1.3s;
}

@keyframes star-twinkle {
    0% { transform: scale(1); }
    40% { transform: scale(1.2); }
    80% { transform: scale(0.8); }
    100% { transform: scale(1); }
}

main {
    width: min(1088px, calc(100% - 48px));
    margin: 0 auto;
    flex: 1;
}

.hero {
    text-align: center;
    padding: 50px 0 22px;
}
.hero.compact {
    padding: 34px 0 12px;
}
.hero.compact h1 {
    font-size: clamp(30px, 4.4vw, 48px);
}
.hero h1 {
    margin: 10px 0 8px;
    font-size: clamp(36px, 5.8vw, 62px);
    line-height: 1.05;
    letter-spacing: 0;
    color: #146bde;
}
.theme-dark .hero h1 { color: #f2f7ff; }
.hero p {
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 18px;
}

.search {
    width: min(608px, 100%);
    height: 48px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 8px;
    padding: 6px;
    border-radius: 999px;
    background: var(--panel-solid);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}
.search input {
    border: 0;
    outline: 0;
    min-width: 0;
    padding: 0 20px;
    color: var(--text);
    background: transparent;
}
.search button {
    border: 0;
    border-radius: 999px;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--blue), var(--blue-2));
    font-weight: 700;
}

.category-strip {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    margin: 8px auto 16px;
    padding: 14px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.category-strip a {
    text-align: center;
    color: #1d6fd4;
    font-weight: 600;
}
.theme-dark .category-strip a { color: #90c4ff; }

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr);
    gap: 16px;
}
.card-panel, .route-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.card-panel {
    padding: 18px;
}
.panel-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text);
}
.panel-title.with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-title span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.site-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}
.site-card {
    min-height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .58);
}
.theme-dark .site-card { background: rgba(255, 255, 255, .04); }
.site-card:hover {
    transform: translateY(-2px);
    border-color: #69aaff;
}
.site-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 8px 18px rgba(22, 92, 180, .08);
}
.site-icon img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}
.site-card strong { font-size: 16px; }
.site-card em {
    font-style: normal;
    font-size: 13px;
    color: var(--muted);
}

.ranking {
    margin: 0;
    padding: 0;
    list-style: none;
}
.ranking li {
    border-bottom: 1px solid var(--line);
}
.ranking li a {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 13px 0;
}
.ranking li a:hover strong {
    color: #0b7cff;
}
.ranking strong {
    font-size: 15px;
}
.ranking span {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    display: grid;
    place-items: center;
    color: #fff;
    background: #ff971f;
    font-size: 12px;
}
.ranking em {
    color: var(--muted);
    font-style: normal;
    font-size: 13px;
}

.feature-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin: 22px auto 34px;
}
.feature-row div {
    text-align: center;
    color: var(--text);
}
.feature-row span {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
}

.route-panel {
    width: min(980px, 100%);
    margin: 18px auto 56px;
    overflow: hidden;
}
.route-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 26px;
    border-bottom: 1px solid var(--line);
}
.eyebrow {
    color: var(--muted);
    font-weight: 700;
}
.route-head h2 {
    margin: 6px 0 0;
    font-size: 22px;
}
.text-link {
    color: #0b7cff;
    font-weight: 700;
}
.route-table {
    padding: 0 22px 18px;
}
.route-row {
    display: grid;
    grid-template-columns: 1.2fr 2.2fr 120px;
    gap: 18px;
    align-items: center;
    min-height: 58px;
    padding: 0 4px;
    border-bottom: 1px solid var(--line);
}
.route-row:hover:not(.route-header) {
    background: rgba(37, 126, 255, .06);
}
.route-header {
    min-height: 54px;
    color: var(--text);
    font-weight: 800;
}
.route-row em {
    color: var(--muted);
    font-style: normal;
}
.route-row span:nth-child(2) {
    color: #2878c9;
    word-break: break-all;
}
.theme-dark .route-row span:nth-child(2) { color: #91c8ff; }
.route-url {
    color: inherit;
    text-decoration: none;
}
.route-url:hover {
    text-decoration: underline;
}
.speed-value {
    justify-self: start;
    min-width: 64px;
    color: #111;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}
.speed-pending {
    color: #111;
}
.speed-timeout {
    color: #111;
}
.theme-dark .speed-value {
    color: #111;
}
.theme-dark .speed-pending {
    color: #111;
}
.theme-dark .speed-timeout {
    color: #111;
}

footer {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 12px 24px;
    color: rgba(255, 255, 255, .82);
    background: #132b57;
}
footer a { color: rgba(255, 255, 255, .82); }

@media (max-width: 900px) {
    .topbar {
        height: auto;
        min-height: 74px;
        padding: 12px 18px;
        gap: 10px;
    }
    .quick-actions { gap: 12px; font-size: 14px; }
    main { width: min(100% - 28px, 1360px); }
    .category-strip { grid-template-columns: repeat(4, 1fr); }
    .content-grid, .feature-row { grid-template-columns: 1fr; }
    .site-grid { grid-template-columns: repeat(2, 1fr); }
    .route-row { grid-template-columns: 1fr; gap: 6px; padding: 16px 4px; }
    .route-header { display: none; }
}

@media (max-width: 560px) {
    .brand-small strong { font-size: 22px; }
    .brand-small em { display: none; }
    .switch { transform: scale(.9); transform-origin: right center; }
    .hero { padding-top: 36px; }
    .search { grid-template-columns: 1fr 86px; }
    .category-strip { grid-template-columns: repeat(2, 1fr); }
    footer { flex-wrap: wrap; gap: 14px; }
}
