:root {
    --primary: #e53935;
    --primary-dark: #c62828;
    --bg: #f5f5f5;
    --bg-white: #ffffff;
    --text: #212121;
    --text-secondary: #757575;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.navbar {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 60px;
}

.nav-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
}

.nav-menu a {
    display: block;
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    transition: background 0.2s;
}

.nav-menu a:hover { background: var(--bg); text-decoration: none; }
.nav-menu a.active { background: var(--primary); color: #fff; }

.nav-search {
    display: flex;
    margin-left: auto;
    gap: 6px;
}

.nav-search input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    width: 200px;
}

.nav-search button {
    padding: 6px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
}

.hero {
    text-align: center;
    padding: 48px 0 32px;
}

.hero h1 { font-size: 32px; margin-bottom: 8px; }
.hero p { color: var(--text-secondary); font-size: 16px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.section { margin-bottom: 32px; }
.section h1 { font-size: 24px; margin-bottom: 16px; }
.section h2 { font-size: 18px; margin-bottom: 12px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.more-link { font-size: 14px; color: var(--text-secondary); white-space: nowrap; }
.more-link:hover { color: var(--primary); text-decoration: none; }

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.app-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px 8px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    text-align: center;
}

.app-card:hover { transform: translateY(-2px); text-decoration: none; }

.app-icon img {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
}

.app-info { margin-top: 8px; width: 100%; }
.app-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-meta { font-size: 12px; color: var(--text-secondary); }
.app-downloads, .app-rating { margin-right: 6px; }
.app-dev { font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rank-list { display: flex; flex-direction: column; gap: 4px; }

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-white);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.rank-item:hover { background: #fafafa; text-decoration: none; }

.rank-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.rank-num.top3 { background: var(--primary); color: #fff; }
.rank-name { flex: 1; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-size: 14px; font-weight: 600; color: var(--primary); flex-shrink: 0; }
.rank-time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.nav-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.nav-card {
    display: block;
    padding: 24px;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: transform 0.2s;
}

.nav-card:hover { transform: translateY(-2px); text-decoration: none; }
.nav-card h3 { font-size: 16px; margin-bottom: 4px; color: var(--text); }
.nav-card p { font-size: 14px; color: var(--text-secondary); }

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-bar input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    flex: 1;
    min-width: 200px;
}

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.filter-bar label {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.filter-bar button {
    padding: 8px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
}

.sort-radio {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.sort-radio input[type="radio"] { accent-color: var(--primary); cursor: pointer; }

.result-count { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }

.app-detail { margin-bottom: 32px; }

.app-detail-header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.app-detail-icon img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    object-fit: contain;
    flex-shrink: 0;
}

.app-detail-info { flex: 1; min-width: 0; }
.app-detail-info h1 { font-size: 22px; margin-bottom: 6px; }
.app-brief { color: var(--text-secondary); font-size: 14px; margin-bottom: 10px; }

.app-meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.app-action-row { display: flex; gap: 10px; }

.btn-primary {
    display: inline-block;
    padding: 8px 20px;
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-hm { background: #e3f2fd; color: #1565c0; }
.badge-atomic { background: #fff3e0; color: #e65100; }
.badge-rating { color: #f57c00; font-weight: 500; }
.badge-download { color: var(--text-secondary); }
.badge-device { background: #e8f5e9; color: #2e7d32; }

.detail-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.detail-card h2 { font-size: 16px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0;
}

.info-item {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}
.info-label {
    width: 80px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-secondary);
}
.info-value {
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.info-mono { font-family: monospace; font-size: 13px; }

.sdk-hint { margin-top: 16px; }
.sdk-hint details { background: var(--bg); border-radius: var(--radius); padding: 10px 14px; }
.sdk-hint summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); user-select: none; }
.sdk-hint summary:hover { color: var(--primary); }
.sdk-hint ul { margin: 8px 0 0 18px; font-size: 13px; color: var(--text-secondary); line-height: 1.8; }
.sdk-hint li { margin-bottom: 2px; }
.sdk-hint strong { color: var(--text); font-weight: 500; }

.app-description { font-size: 14px; line-height: 1.8; color: var(--text); }

.recommend-section { margin-top: 8px; }
.recommend-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.recommend-scroll::-webkit-scrollbar { height: 4px; }
.recommend-scroll::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.recommend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    width: 200px;
    transition: transform 0.15s;
}
.recommend-item:hover { transform: translateY(-2px); text-decoration: none; }
.recommend-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: contain;
    flex-shrink: 0;
}
.recommend-info { min-width: 0; }
.recommend-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recommend-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.data-table { width: 100%; border-collapse: collapse; background: var(--bg-white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { padding: 12px 16px; text-align: left; font-size: 13px; color: var(--text-secondary); background: var(--bg); border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #fafafa; }
.rank-col { width: 60px; text-align: center; font-weight: 600; }
.score-col { color: var(--primary); font-weight: 600; }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
}

.page-btn {
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
}

.page-btn:hover { background: var(--primary); color: #fff; text-decoration: none; border-color: var(--primary); }
.page-info { font-size: 14px; color: var(--text-secondary); }

.empty { text-align: center; padding: 40px; color: var(--text-secondary); font-size: 16px; }

.footer {
    text-align: center;
    padding: 24px;
    background: var(--bg-white);
    margin-top: 40px;
    font-size: 13px;
    color: var(--text-secondary);
}

.card-hint { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.section-desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }

.compat-tips { display: flex; flex-direction: column; gap: 16px; }
.tip-item { padding: 12px; background: var(--bg); border-radius: var(--radius); }
.tip-item strong { margin-right: 8px; }
.tip-item span { font-weight: 600; color: var(--primary); }
.tip-item p { margin-top: 4px; font-size: 13px; color: var(--text-secondary); }

.substance-icon img { display: none; }
.substance-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #fb8c00);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    flex-shrink: 0;
}
.substance-placeholder-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #fb8c00);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}
.substance-icon-lg .substance-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 20px;
    font-size: 40px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 8px 0;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb span { color: var(--text); }
.bc-sep { margin: 0 4px; color: #ccc; }

.app-list { display: flex; flex-direction: column; gap: 4px; }
.app-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-white);
    border-radius: var(--radius);
    transition: background 0.2s;
}
.app-list-item:hover { background: #fafafa; text-decoration: none; }
.app-list-detail { gap: 16px; padding: 12px 16px; }
.app-list-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}
.app-list-body { flex: 1; min-width: 0; }
.app-list-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-list-brief { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-list-desc { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-list-meta { font-size: 12px; color: var(--text-secondary); display: flex; gap: 8px; margin-top: 2px; flex-wrap: wrap; align-items: center; }
.app-list-meta .app-rating { color: var(--primary); font-weight: 500; }
.app-list-meta .app-dev a { color: var(--text-secondary); }
.app-list-meta .app-dev a:hover { color: var(--primary); }
.app-list-meta .app-cat { color: var(--text-secondary); }
.app-cat { color: var(--primary); }

.apps-layout { display: flex; gap: 24px; }

.kind-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.kind-tab {
    display: inline-block;
    padding: 6px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-secondary);
    background: var(--bg-white);
    transition: all 0.2s;
}
.kind-tab:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.kind-tab.active { background: var(--primary); color: #fff; }

.app-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}
.app-card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 12px 6px;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    text-align: center;
    min-height: 100px;
}
.app-card-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); text-decoration: none; }
.app-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: contain;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.app-card-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    line-height: 1.4;
}
.app-card-brief {
    display: none;
}
.app-card-info {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    gap: 6px;
    justify-content: center;
}
.app-card-info .app-card-rating { color: #f57c00; font-weight: 500; }

.dev-app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.dev-app-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px 12px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    text-align: center;
}
.dev-app-card:hover { transform: translateY(-2px); text-decoration: none; }
.dev-app-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: cover;
    margin-bottom: 8px;
}
.dev-app-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.dev-app-desc {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    margin-top: 2px;
}
.dev-app-meta {
    margin-top: 6px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.apps-sidebar {
    width: 160px;
    flex-shrink: 0;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 80px;
    align-self: flex-start;
}
.cat-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.cat-item {
    display: block;
    padding: 6px 8px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: 4px;
    margin-bottom: 2px;
}
.cat-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.cat-item.active { background: var(--primary); color: #fff; }
.apps-main { flex: 1; min-width: 0; }


.rank-desc {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .nav-inner { flex-wrap: wrap; height: auto; padding: 12px 20px; }
    .nav-menu { order: 3; width: 100%; overflow-x: auto; }
    .nav-search { width: 100%; order: 2; }
    .nav-search input { flex: 1; width: auto; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .hero h1 { font-size: 24px; }
    .app-detail-header { flex-direction: column; align-items: center; text-align: center; }
    .app-meta-row { justify-content: center; }
    .app-action-row { justify-content: center; }
    .apps-layout { flex-direction: column; }
    .apps-sidebar { width: 100%; position: static; display: flex; flex-wrap: wrap; gap: 4px; }
    .cat-title { width: 100%; }
    .cat-item { display: inline-block; }
    .info-grid { grid-template-columns: 1fr; }
    .detail-tabs { overflow-x: auto; }
    .recommend-item { width: 170px; }
}

.dev-search-form {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto 24px;
}
.dev-search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.2s;
}
.dev-search-input:focus { border-color: var(--primary); outline: none; }
.dev-search-btn {
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}
.dev-search-btn:hover { background: var(--primary-dark); }