* {
    box-sizing: border-box;
}

/* 全局布局 */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f5f7fb;
    color: #212529;
}

.app-header {
    background: linear-gradient(135deg, #343a40, #212529);
    color: #fff;
    text-align: center;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.app-header h1 {
    margin: 0;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
}

.app-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

.app-footer {
    text-align: center;
    padding: 1rem 0 2rem;
    font-size: 0.8rem;
    color: #868e96;
}

/* 布局：侧边栏 + 主区域 */
.layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.app-sidebar {
    width: 220px;
    min-width: 200px;
}

.main-column {
    flex: 1;
}

/* Panel 通用样式 */
.panel {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    padding: 0.75rem 1rem;
    margin-bottom: 0.9rem;
}

.panel-controls {
    margin-top: 0.25rem;
}

.panel-sidebar {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.sidebar-section + .sidebar-section {
    margin-top: 1rem;
}

.sidebar-section h2 {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    color: #495057;
}

/* 控制区 */
.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.control-row-line2 {
    align-items: center;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-row input[type="text"] {
    flex: 1 1 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #ced4da;
    font-size: 0.95rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.control-group .label {
    font-size: 0.85rem;
    color: #495057;
}

#platform-select {
    padding: 0.35rem 0.55rem;
    border-radius: 0.5rem;
    border: 1px solid #ced4da;
    font-size: 0.9rem;
}

/* IPv6 开关（侧边栏复用） */
.ipv6-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ced4da;
    transition: .2s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: #0d6efd;
}

.switch input:checked + .slider:before {
    transform: translateX(16px);
}

.switch-label {
    font-size: 0.85rem;
    margin-left: 0.2rem;
}

/* 按钮 */
.btn {
    border-radius: 0.6rem;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.45rem 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-primary {
    background: #0d6efd;
    color: #fff;
}

.btn-primary:disabled {
    background: #7ca9ff;
    cursor: default;
}

.btn-primary:hover:not(:disabled) {
    background: #0b5ed7;
}

.btn-secondary {
    background: #fff;
    color: #0d6efd;
    border: 1px solid #0d6efd;
}

.btn-secondary:hover {
    background: #e7f1ff;
}

.btn-full {
    width: 100%;
}

.btn-text {
    background: transparent;
    border: none;
    color: #868e96;
    font-size: 0.85rem;
}

.btn-link {
    background: transparent;
    border: none;
    color: #0d6efd;
    font-size: 0.9rem;
}

.btn-link:hover {
    text-decoration: underline;
}

/* 过滤条（仿 Streamlit 单选） */
.panel-filter {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.filter-row .label {
    font-size: 0.85rem;
    color: #495057;
}

.filter-radio-group {
    display: inline-flex;
    gap: 0.4rem;
    background: #f1f3f5;
    padding: 2px;
    border-radius: 999px;
}

.filter-pill {
    border: none;
    border-radius: 999px;
    padding: 0.2rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    background: transparent;
    color: #495057;
}

.filter-pill.active {
    background: #0d6efd;
    color: #fff;
}

.filter-summary {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #868e96;
}

/* 登录面板 */
.panel-login {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.login-header h2 {
    margin: 0;
    font-size: 1rem;
}

.login-body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-body img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    margin-bottom: 0.3rem;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
}

.status-text {
    font-size: 0.85rem;
    margin: 0.2rem 0 0.4rem;
    color: #495057;
}

.login-actions {
    display: flex;
    gap: 0.5rem;
}

/* 结果区域 */
.panel-results {
    padding-top: 0.7rem;
}

.result-block {
    margin-bottom: 0.8rem;
}

.result-block-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.3rem;
}

.result-block-header h2 {
    margin: 0;
    font-size: 1rem;
}

.results-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.no-results {
    text-align: center;
    padding: 1rem 0.5rem;
    font-size: 0.9rem;
    color: #868e96;
}

/* 卡片样式（仿 streamlit） */
.card {
    background: #fff;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
}

.card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.card-body {
    padding: 0.6rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: #868e96;
}

.badge {
    font-size: 0.78rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    color: #fff;
}

.badge.a {
    background: #e03131;
}

.badge.b {
    background: #1c7ed6;
}

/* 下载按钮和进度 */
.card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.btn-download-main {
    width: 100%;
}

.progress-container {
    width: 100%;
    background: #e9ecef;
    border-radius: 999px;
    overflow: hidden;
    height: 0.45rem;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4dabf7, #0d6efd);
    transition: width 0.25s ease;
}

.progress-text {
    font-size: 0.78rem;
    color: #868e96;
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 响应式：侧边栏在窄屏时变为上方 */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    .app-sidebar {
        width: 100%;
        min-width: 0;
    }
}

/* 响应式：卡片两列 */
@media (min-width: 768px) {
    .results-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
