:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-2: #7c3aed;
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e8eaf0;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============ 顶部导航 ============ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand { display: flex; align-items: center; text-decoration: none; }

.brand-logo {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}

.lang-switch {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: #eef0f6;
    border-radius: 999px;
}

.lang-switch button {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: all .18s;
}

.lang-switch button:hover { color: var(--text); }

.lang-switch button.active {
    background: #fff;
    color: var(--brand);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

/* ============ Hero 搜索区 ============ */
.hero {
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(255, 255, 255, .25), transparent 60%),
        linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    padding: 72px 20px 84px;
    text-align: center;
}

.hero-inner { max-width: 720px; margin: 0 auto; }

.hero h1 {
    margin: 0;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -.5px;
    line-height: 1.2;
}

.hero-sub {
    margin: 14px 0 34px;
    font-size: 16px;
    opacity: .9;
}

.search-wrap {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    display: flex;
}

.search-wrap input {
    width: 100%;
    height: 58px;
    padding: 0 56px 0 50px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    color: var(--text);
    background: #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22);
    outline: none;
}

.search-wrap input::placeholder { color: #9ca3af; }

.search-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: #f1f2f8;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, color .18s;
}

.search-toggle:hover { background: #e8eaf2; color: var(--brand); }

.search-clear {
    position: absolute;
    right: 52px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #e8eaf2;
    color: var(--muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition: background .18s, color .18s;
}
.search-clear:hover { background: #fee2e2; color: #b91c1c; }
.search-wrap.has-selection .search-clear { display: flex; }
.search-wrap.has-selection input { padding-right: 100px; }

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: #fff;
    color: var(--text);
    border-radius: 14px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, .2);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    text-align: left;
    z-index: 30;
}

.search-dropdown.open { display: block; }

.search-dropdown li {
    padding: 11px 18px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.search-dropdown li:hover { background: #f5f6fb; }

.search-dropdown .li-name { font-weight: 500; }

.search-dropdown .li-code {
    color: var(--muted);
    font-size: 12px;
    background: #eef0f6;
    padding: 2px 8px;
    border-radius: 999px;
}

.search-dropdown li.no-result { color: var(--muted); cursor: default; justify-content: center; }
.search-dropdown li.no-result:hover { background: transparent; }

/* ============ 内容区 ============ */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 36px 20px 64px;
}

.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.result-head h2 { margin: 0; font-size: 22px; font-weight: 700; }

.result-model {
    font-size: 14px;
    color: var(--brand);
    background: #eef0ff;
    padding: 4px 14px;
    border-radius: 999px;
    font-weight: 600;
}

.result-model:empty { display: none; }

/* 固件卡片列表 */
.fw-list { display: flex; flex-direction: column; gap: 16px; }

.fw-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    transition: transform .18s, box-shadow .18s, border-color .18s;
}

.fw-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .08);
    border-color: #d8dbf3;
}

.fw-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.fw-version {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fw-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    flex-wrap: wrap;
}

.fw-meta b { color: var(--text); font-weight: 600; }

.meta-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #c6cad6;
}

.fw-changelog {
    margin-top: 14px;
    padding: 12px 16px;
    background: #f8f9fd;
    border-radius: 10px;
    font-size: 14px;
    color: #4b5563;
    white-space: pre-line;
    line-height: 1.7;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
    transition: transform .18s, box-shadow .18s, filter .18s;
}

.btn-download:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(79, 70, 229, .36); filter: brightness(1.05); }

/* badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-new {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 10px rgba(16, 185, 129, .3);
}

.badge-model {
    background: #eef0ff;
    color: #4f46e5;
}

.badge-hw {
    background: #fff7ed;
    color: #c2410c;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f3f4f6; color: #6b7280; }

/* 空状态 / 加载 */
.empty { text-align: center; color: var(--muted); padding: 72px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 15px; }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    padding: 64px 20px;
    font-size: 15px;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 页脚 */
.site-footer {
    text-align: center;
    padding: 28px 20px;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.site-footer p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* 响应式 */
@media (max-width: 640px) {
    .hero { padding: 56px 16px 64px; }
    .hero h1 { font-size: 30px; }
    .hero-sub { font-size: 14px; }
    .fw-card { padding: 16px 18px; }
    .fw-version { font-size: 18px; }
}

/* ============ 后台 ============ */
.admin-nav {
    background: #111827;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 16px rgba(0, 0, 0, .15);
}

.admin-nav .inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 60px;
    gap: 6px;
}

.admin-nav .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin-right: 20px;
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    white-space: nowrap;
}

.admin-nav .brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .4);
}

.admin-nav a.nav-link {
    color: #d1d5db;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
    transition: background .18s, color .18s;
}

.admin-nav a.nav-link:hover { background: #1f2937; color: #fff; }

.admin-nav a.nav-link.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
}

.admin-nav .spacer { flex: 1; }

/* 后台语言切换（深色胶囊） */
.admin-nav .lang-switch {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
}

.admin-nav .lang-switch a {
    border: none;
    background: transparent;
    color: #d1d5db;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s;
}

.admin-nav .lang-switch a:hover { color: #fff; }

.admin-nav .lang-switch a.active {
    background: #fff;
    color: var(--brand);
    font-weight: 600;
}

.admin-nav a.logout-link { color: #fca5a5; }
.admin-nav a.logout-link:hover { background: rgba(252, 165, 165, .12); color: #fecaca; }

.admin-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 56px;
}

.admin-content h2 { margin: 0 0 20px; font-size: 22px; font-weight: 700; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.card h3 { margin-top: 0; font-size: 16px; }

/* 编辑表单：锚点定位（避开 sticky 导航）+ 编辑态高亮 */
#model-form { scroll-margin-top: 80px; }
.card-editing {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15), 0 1px 3px rgba(0, 0, 0, .05);
}

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* 登录页 */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1000px 500px at 50% -10%, rgba(255, 255, 255, .2), transparent 60%),
        linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}

.login-box h1 { margin: 0 0 8px; font-size: 24px; text-align: center; }

.login-langs {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 3px;
    margin: 0 0 24px;
    background: #eef0f6;
    border-radius: 999px;
}

.login-langs a {
    font-size: 13px;
    padding: 5px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    transition: all .18s;
}

.login-langs a:hover { color: var(--text); }

.login-langs a.active {
    background: #fff;
    color: var(--brand);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead th {
    text-align: left;
    padding: 12px 14px;
    background: #f8fafc;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid #f1f2f6;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbff; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .28);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    min-width: 36px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    color: var(--text);
    text-align: center;
}
.pagination a:hover { background: #f3f4f6; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 14px;
    background: #fff;
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
    overflow: hidden;
    animation: modal-pop .18s ease;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    background: transparent;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal form { padding: 22px; }
.modal .form-actions { margin-top: 8px; }
body.modal-open { overflow: hidden; }
@keyframes modal-pop {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
}

/* 后台响应式 */
@media (max-width: 768px) {
    .admin-nav .inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
    .admin-nav .brand { margin-right: auto; }
}
