:root {
    --primary: #2f6fed;
    --primary-dark: #1d4fc4;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1c2331;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #e0433f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }

.site-header, .admin-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.site-header .wrap, .admin-header .wrap {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 64px;
}
.logo { font-size: 20px; font-weight: 700; color: var(--text); white-space: nowrap; }

.search-form { flex: 1; display: flex; max-width: 420px; }
.search-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px 0 0 6px;
    font-size: 14px;
}
.search-form button {
    padding: 8px 16px;
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
}

.nav { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.admin-name { color: var(--muted); font-size: 13px; }

.main { padding: 32px 20px 64px; }

.filters { margin-bottom: 20px; }
.browse-tabs { display: flex; gap: 8px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.browse-tabs a { padding: 10px 20px 12px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.browse-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.browse-tabs a:hover { color: var(--primary); text-decoration: none; }
.browse-tabs a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.filter-form { display: flex; gap: 12px; flex-wrap: wrap; }
.filter-form select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.page-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 20px; font-size: 22px; }
.page-title .count { font-size: 14px; color: var(--muted); font-weight: normal; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.card-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: block;
    transition: box-shadow .15s, transform .15s;
}
.card-item:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); transform: translateY(-2px); text-decoration: none; }
.card-thumb { position: relative; aspect-ratio: 1.58 / 1; background: #eef1f6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card-type-pill { position: absolute; left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .94); color: #263447; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); font-size: 11px; font-weight: 600; line-height: 1.5; pointer-events: none; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.public-page .card-thumb { border-radius: 10px; }
@supports ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
    .card-type-pill { background: rgba(255, 255, 255, .58); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .45); }
}
.card-info { padding: 12px 14px; }
.card-info h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); }
.card-info .card-bank { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.card-info .meta { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.card-info .stats { margin: 0; font-size: 12px; color: var(--muted); }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.pagination { display: flex; gap: 6px; margin-top: 28px; justify-content: center; }
.pagination a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 6px;
    border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover { text-decoration: none; border-color: var(--primary); }

.card-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; margin-bottom: 40px; }
.detail-image { background: #eef1f6; border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.detail-image img { width: 100%; display: block; }
.detail-info h1 { margin-top: 0; }
.detail-meta { list-style: none; padding: 0; margin: 16px 0; color: var(--muted); line-height: 1.9; }
.tags { margin: 12px 0; }
.tag {
    display: inline-block; background: #eef1f6; color: var(--text);
    padding: 3px 10px; border-radius: 20px; font-size: 12px; margin: 0 6px 6px 0;
}
.description { line-height: 1.7; color: var(--text); }
.btn-download {
    display: inline-block; margin-top: 20px; padding: 12px 28px;
    background: var(--primary); color: #fff; border-radius: 8px; font-weight: 600;
}
.btn-download:hover { background: var(--primary-dark); text-decoration: none; }

.related { margin-top: 40px; }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 13px; }
.footer-submission { margin-bottom: 8px; }
.submission-button { border: 0; padding: 6px 0; background: none; color: var(--primary); font: inherit; cursor: pointer; }
.submission-button:hover { text-decoration: underline; }
.submission-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.submission-dialog { width: min(440px, calc(100% - 40px)); max-height: calc(100% - 40px); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: #fff; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
.submission-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.submission-dialog-content { padding: 28px; }
.submission-dialog h2 { margin: 0 0 16px; font-size: 20px; }
.submission-dialog p { margin: 0 0 24px; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.submission-dialog form { display: flex; justify-content: flex-end; }
.submission-close { padding: 9px 18px; border: 1px solid var(--border); border-radius: 8px; background: #f5f5f7; color: var(--text); font: inherit; cursor: pointer; }
.submission-close:hover { background: #eaeaec; }
.submission-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

/* ---- Admin ---- */
.admin-auth { max-width: 380px; margin: 60px auto; background: #fff; padding: 32px; border-radius: 10px; border: 1px solid var(--border); }
.admin-auth h1 { margin-top: 0; font-size: 20px; }
.admin-auth .hint { color: var(--muted); font-size: 13px; }
.admin-auth form label, .card-form label {
    display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted);
}
.admin-auth input, .card-form input, .card-form select, .card-form textarea {
    display: block; width: 100%; margin-top: 6px; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 6px; font-size: 14px; color: var(--text);
}
.admin-auth button, .card-form button, .inline-form button {
    padding: 10px 20px; background: var(--primary); color: #fff; border: none;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.error { color: var(--danger); }
.success { color: #1a7f37; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; text-align: center; }
.stat-card .num { display: block; font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .label { color: var(--muted); font-size: 13px; }

.btn {
    display: inline-block; padding: 8px 16px; background: var(--primary); color: #fff;
    border-radius: 6px; font-size: 13px; margin-right: 8px;
}
.btn:hover { text-decoration: none; background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.admin-table th, .admin-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px;
}
.admin-table th { background: #f8f9fb; color: var(--muted); }
.admin-table input:not([type="hidden"]) { max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.admin-table input[type="number"] { width: 90px; }
.thumb-sm { width: 60px; height: 40px; object-fit: cover; border-radius: 4px; }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font-size: 13px; }
.link-danger:hover { text-decoration: underline; }

.inline-form { display: flex; gap: 8px; margin-bottom: 20px; }
.inline-form input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; }

.card-form { max-width: 560px; background: #fff; padding: 24px; border-radius: 10px; border: 1px solid var(--border); }
.current-image { margin-bottom: 14px; }
.card-form .checkbox-label { display: flex; align-items: center; gap: 8px; }
.card-form input[type="checkbox"] { width: auto; margin: 0; }
.card-form .choice-group { min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.choice-group legend { padding: 0; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.choice-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.card-form .choice-button { position: relative; margin: 0; cursor: pointer; }
.card-form .choice-button input { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }
.choice-button span { display: block; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; line-height: 1.5; }
.choice-button:hover span { border-color: var(--primary); }
.choice-button input:checked + span { background: #edf3ff; border-color: var(--primary); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
.choice-button input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 3px; }
.refer-badge { display: inline-block; padding: 4px 9px; margin-bottom: 8px; border-radius: 6px; background: #e7f5ed; color: #17653a; font-size: 12px; font-weight: 600; }
.application-info { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); overflow-wrap: anywhere; }

/* Card detail / download */
.detail-breadcrumb { display: flex; gap: 8px; align-items: center; margin: 0 0 24px; font-size: 13px; color: var(--muted); min-width: 0; }
.detail-breadcrumb a { color: var(--muted); }
.detail-breadcrumb span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.download-detail { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 48px; align-items: start; }
.preview-panel { display: flex; align-items: center; justify-content: center; min-height: 360px; padding: 48px; background: #fff; border: 1px solid var(--border); border-radius: 16px; }
.preview-panel img { display: block; max-width: 100%; max-height: 420px; height: auto; border-radius: 12px; box-shadow: 0 12px 32px rgba(28, 35, 49, .14); }
.download-detail .detail-info { min-width: 0; overflow-wrap: anywhere; }
.download-detail h1 { font-size: clamp(24px, 2.6vw, 30px); line-height: 1.3; letter-spacing: -.02em; margin: 0 0 6px; }
.detail-sub { margin: 0; font-size: 14px; color: var(--muted); }
.download-detail .detail-meta { margin: 24px 0; padding: 0; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.detail-meta div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-meta dt { color: var(--muted); flex-shrink: 0; }
.detail-meta dd { margin: 0; text-align: right; }
.download-detail .tags { margin: 0 0 16px; }
.download-detail .description { font-size: 14px; line-height: 1.8; color: #4b5563; margin: 0 0 16px; }
.download-action { margin-top: 28px; }
.download-detail .btn-download { display: flex; justify-content: center; align-items: center; gap: 8px; width: 100%; margin: 0; padding: 14px 20px; border-radius: 10px; transition: background .15s; }
.download-action p { font-size: 12px; text-align: center; color: var(--muted); margin: 10px 0 0; }
.download-detail .application-info { margin-top: 28px; padding: 20px 0 0; border-top: 1px solid var(--border); }
.application-info h2 { font-size: 15px; margin: 0 0 12px; }
.download-detail .application-info .btn { margin: 0; background: #fff; color: var(--text); padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; }
.download-detail .application-info .btn:hover { border-color: var(--primary); color: var(--primary); }
.related-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); padding-top: 32px; margin-bottom: 20px; }
.related-heading h2 { font-size: 18px; margin: 0; }
.related-heading a { font-size: 13px; white-space: nowrap; }
.public-page { background: #f5f5f7; }
.public-page .site-header { background: rgba(250, 250, 252, .94); border-bottom: 1px solid rgba(0, 0, 0, .07); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.public-page .site-header .wrap { height: 76px; gap: 28px; }
.public-page .logo { color: #1d1d1f; font-size: 22px; font-weight: 600; letter-spacing: -.8px; }
.public-page .logo:hover { text-decoration: none; }
.public-page .site-header .nav { display: none; }
.public-page .search-form { margin-left: auto; flex: 0 1 300px; max-width: 300px; background: #eaeaec; border: 1px solid transparent; border-radius: 10px; overflow: hidden; }
.public-page .search-form:focus-within { border-color: #86868b; background: #fff; }
.public-page .search-form input { width: 0; min-width: 0; border: 0; border-radius: 0; background: transparent; padding: 10px 0 10px 14px; font-size: 14px; color: #1d1d1f; outline: none; }
.public-page .search-form input::placeholder { color: #747479; }
.public-page .search-form button { display: flex; align-items: center; justify-content: center; min-width: 44px; padding: 10px; background: transparent; color: #626267; border-radius: 0; }
.public-page .search-form button:hover { color: #1d1d1f; }
.public-page .main { padding-top: 36px; }
.public-page .browse-tabs { display: inline-flex; gap: 3px; margin: 0 0 28px; padding: 3px; border: 0; border-radius: 10px; background: #e8e8ed; }
.public-page .browse-tabs a { min-width: 76px; padding: 8px 20px; border: 0; border-radius: 7px; text-align: center; font-size: 13px; line-height: 20px; font-weight: 500; color: #626267; }
.public-page .browse-tabs a.active { color: #1d1d1f; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .09); }
.public-page .filters { margin-bottom: 28px; }
.public-page .filter-form { align-items: center; gap: 10px; }
.public-page .filter-form select { appearance: none; -webkit-appearance: none; min-height: 42px; max-width: 230px; padding: 10px 34px 10px 14px; border: 1px solid #dedee3; border-radius: 9px; background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m2 2 4 4 4-4' fill='none' stroke='%23747479' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center; color: #424245; font-family: inherit; font-size: 13px; cursor: pointer; text-overflow: ellipsis; }
.public-page .filter-form select:hover { border-color: #a9a9af; }
.public-page .clear-filters { color: #6e6e73; font-size: 12px; padding: 10px 4px; }
.public-page .page-title { color: #6e6e73; font-size: 14px; font-weight: 400; margin-bottom: 20px; }
.public-page .site-footer { border-color: #dedee3; color: #86868b; font-size: 11px; line-height: 1.7; }
.public-page .site-header a:focus-visible, .public-page .search-form button:focus-visible, .public-page .filter-form select:focus-visible, .public-page .clear-filters:focus-visible { outline: 2px solid #0071e3; outline-offset: 3px; }
.public-page .pagination a { border-color: transparent; color: #6e6e73; border-radius: 8px; font-size: 13px; }
.public-page .pagination a.active { background: #e8e8ed; color: #1d1d1f; }
.download-detail a:focus-visible, .detail-breadcrumb a:focus-visible, .related a:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.public-page .detail-breadcrumb { color: #86868b; font-size: 12px; }
.public-page .detail-breadcrumb a { color: #626267; }
.public-page .preview-panel { border-color: #e5e5ea; border-radius: 18px; }
.public-page .preview-panel img { box-shadow: 0 8px 24px rgba(0, 0, 0, .09); }
.public-page .download-detail h1 { color: #1d1d1f; font-weight: 600; letter-spacing: -.6px; }
.public-page .detail-sub, .public-page .detail-meta dt { color: #6e6e73; }
.public-page .detail-meta dd { color: #1d1d1f; }
.public-page .detail-meta, .public-page .detail-meta div, .public-page .application-info, .public-page .related-heading { border-color: #dedee3; }
.public-page .download-detail .description { color: #626267; }
.public-page .download-detail .tag { background: #e8e8ed; color: #626267; border-radius: 6px; }
.public-page .download-detail .btn-download { background: #1d1d1f; border-radius: 10px; font-size: 14px; font-weight: 500; min-height: 48px; }
.public-page .download-detail .btn-download:hover { background: #363638; }
.public-page .download-detail .application-info .btn { background: #e8e8ed; border-color: transparent; color: #1d1d1f; border-radius: 10px; }
.public-page .download-detail .application-info .btn:hover { background: #dcdce2; }
.public-page .application-info h2, .public-page .related-heading h2 { color: #1d1d1f; font-weight: 500; }
.public-page .related-heading a { color: #626267; }
.language-switch { position: relative; flex-shrink: 0; font-size: 13px; white-space: nowrap; }
.language-switch summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #dedee3; border-radius: 9px; color: #424245; cursor: pointer; list-style: none; }
.language-switch summary::-webkit-details-marker { display: none; }
.language-switch[open] summary { background: #e8e8ed; }
.language-switch .language-options { position: absolute; right: 0; top: calc(100% + 8px); min-width: 160px; padding: 5px; background: #fff; border: 1px solid #e5e5ea; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.1); z-index: 20; }
.language-options a { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 12px; color: #424245; border-radius: 7px; }
.language-options a:hover, .language-options a[aria-current="true"] { background: #f5f5f7; color: #1d1d1f; text-decoration: none; }
.language-switch summary:focus-visible, .language-options a:focus-visible { outline: 2px solid #0071e3; outline-offset: 2px; }

@media (max-width: 720px) {
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .card-info { padding: 10px; min-width: 0; }
    .card-info h3 { font-size: 14px; overflow-wrap: anywhere; }
    .card-info .card-bank { font-size: 12px; }
    .filter-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .filter-form select { width: 100%; min-width: 0; }
    .page-title { flex-wrap: wrap; font-size: 20px; }
    .pagination { flex-wrap: wrap; }
    .download-detail { gap: 24px; }
    .preview-panel { min-height: 0; padding: 24px; }
    .card-detail { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .site-header .wrap { flex-wrap: wrap; height: auto; padding: 12px 20px; }
    .search-form { order: 3; width: 100%; }
    .search-form input { min-width: 0; }
    .public-page .site-header .wrap { flex-wrap: wrap; height: auto; min-height: 68px; padding: 12px 20px; gap: 10px 16px; }
    .public-page .logo { font-size: 20px; }
    .public-page .language-switch { margin-left: auto; }
    .public-page .search-form { order: 3; flex: 1 0 100%; width: 100%; max-width: none; margin-left: 0; }
    .public-page .search-form input { font-size: 16px; padding-left: 10px; }
    .public-page .main { padding-top: 24px; }
    .public-page .browse-tabs { margin-bottom: 22px; }
    .public-page .filters { margin-bottom: 22px; }
    .public-page .filter-form select { max-width: none; font-size: 14px; }
}
