/* ==========================================================================
   CodeShield UI · 设计令牌与基础重置
   1:1 复刻 React 版视觉语言（Geist 字体 / 黑白灰 + 薄荷绿点缀 / 紧凑排版）
   ========================================================================== */

@font-face {
    font-family: 'GeistSans';
    src: url('/assets/codeshield/fonts/GeistSans.woff2') format('woff2');
    font-display: swap;
    font-weight: 100 900;
}

@font-face {
    font-family: 'GeistMono';
    src: url('/assets/codeshield/fonts/GeistMono.woff2') format('woff2');
    font-display: swap;
    font-weight: 100 900;
}

:root {
    --bg: #ffffff;
    --fg: #0a0a0a;
    --muted: #6b6b6b;
    --border: #e5e5e5;
    --soft: #f7f7f7;
    --accent: #31d7b2;
    --accent-ink: #0b9e79;
    --accent-soft: #e8fbf4;
    --violet: #8255dd;
    --violet-soft: #f1ebff;
    --cyan: #168fbc;
    --cyan-soft: #e8f8ff;
    --amber: #c78300;
    --amber-soft: #fff6df;
    --danger: #b13939;
    --danger-soft: #fff0f0;
    --mono: 'GeistMono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans: 'GeistSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --radius: 14px;
    --radius-sm: 10px;
    --content: 1120px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; }
button { font-family: inherit; }

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* --------------------------------------------------------------------------
   通用组件：按钮 / 徽章 / 面板 / 表单
   -------------------------------------------------------------------------- */

.cs-shell { width: min(calc(100% - 48px), var(--content)); margin-inline: auto; }

/* 胶囊按钮 */
.cs-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform .2s, background .2s, box-shadow .2s;
    line-height: 1.2;
    white-space: nowrap;
}
.cs-pill:hover { transform: translateY(-1px); }
.cs-pill:active { transform: translateY(0); }
.cs-pill.cs-black { background: var(--fg); color: var(--bg); }
.cs-pill.cs-black:hover { background: #202020; }
.cs-pill.cs-light { border-color: var(--border); background: var(--bg); color: var(--fg); }
.cs-pill.cs-light:hover { background: var(--soft); }
.cs-pill.cs-accent { background: var(--accent-ink); color: #fff; }
.cs-pill.cs-accent:hover { background: #0a8c6c; }
.cs-pill:disabled { opacity: .65; cursor: not-allowed; transform: none; }

/* 文本链接 */
.cs-text-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: none;
    padding: 0;
    color: var(--fg);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.cs-text-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* 图标按钮 */
.cs-icon-btn {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    transition: background .18s, color .18s;
}
.cs-icon-btn:hover { background: var(--soft); color: var(--fg); }

/* 返回按钮 */
.cs-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .18s;
}
.cs-back-btn:hover { background: var(--soft); }

/* 面板 */
.cs-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    padding: 22px;
    transition: border-color .22s, box-shadow .22s;
}
.cs-panel:hover { border-color: #d2d2d2; }
.cs-panel > .cs-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.cs-panel h2,
.cs-panel .cs-panel-title h2 {
    font-size: 15px;
    margin: 0;
    letter-spacing: -.02em;
    font-weight: 600;
}

/* 小标题（ eyebrow / kicker ） */
.cs-kicker {
    color: var(--muted);
    font: 600 12px var(--mono);
    letter-spacing: .16em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* 徽章 */
.cs-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    font: 600 11px var(--mono);
    white-space: nowrap;
}
.cs-badge.cs-green { color: #078466; background: #e6faf3; }
.cs-badge.cs-violet { color: #7350c8; background: #f0eaff; }
.cs-badge.cs-cyan { color: #147f9f; background: #e5f7ff; }
.cs-badge.cs-amber { color: #a86e00; background: #fff3d9; }
.cs-badge.cs-red { color: var(--danger); background: var(--danger-soft); }
.cs-badge.cs-gray { color: var(--muted); background: var(--soft); }

/* 表单控件 */
.cs-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.cs-field > span { font-size: 12px; }
.cs-input,
.cs-select,
.cs-textarea {
    height: 38px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--fg);
    padding: 0 10px;
    font: 13px var(--sans);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.cs-textarea { height: auto; min-height: 110px; padding: 10px; resize: vertical; line-height: 1.5; }
.cs-input:focus,
.cs-select:focus,
.cs-textarea:focus {
    border-color: #21b693;
    box-shadow: 0 0 0 3px rgba(33, 182, 147, .11);
}
.cs-input::placeholder,
.cs-textarea::placeholder { color: #a9b0ad; }

/* 开关行 */
.cs-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.cs-switch:last-child { border-bottom: 0; }
.cs-switch > span { display: flex; flex-direction: column; gap: 3px; }
.cs-switch b { font-size: 13px; font-weight: 600; }
.cs-switch small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.cs-switch input { display: none; }
.cs-switch i {
    width: 34px;
    height: 20px;
    border-radius: 99px;
    background: #d6ddda;
    position: relative;
    flex: 0 0 auto;
    transition: background .2s;
}
.cs-switch i:after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform .2s;
}
.cs-switch input:checked + i { background: #18b38d; }
.cs-switch input:checked + i:after { transform: translateX(14px); }

/* 上传区 */
.cs-upload {
    min-height: 190px;
    border: 1px dashed #c9cfce;
    border-radius: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: #929b98;
    background: #fbfcfc;
    cursor: pointer;
    text-align: center;
    padding: 20px;
    transition: border-color .2s, background .2s, box-shadow .2s;
}
.cs-upload:hover,
.cs-upload.selected,
.cs-upload.dragging {
    border-color: #18a984;
    background: #f3fffb;
    color: var(--fg);
    box-shadow: 0 0 0 3px rgba(24, 169, 132, .08);
}
.cs-upload svg { transition: transform .25s; }
.cs-upload:hover svg { transform: translateY(-2px); }
.cs-upload b { font-size: 14px; font-weight: 600; max-width: 92%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-upload span { font-size: 12px; color: var(--muted); }
.cs-upload small { color: #999; font: 11px var(--mono); margin-top: 4px; }
.cs-upload input[type='file'] { display: none; }

/* 表格 */
.cs-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 11px; }
.cs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.cs-table th,
.cs-table td {
    text-align: left;
    padding: 12px 12px;
    border-bottom: 1px solid var(--border);
}
.cs-table th { background: var(--soft); font-weight: 600; font-size: 12px; white-space: nowrap; }
.cs-table tr:last-child td { border-bottom: 0; }
.cs-table tbody tr { transition: background .18s; }
.cs-table tbody tr:hover { background: var(--soft); }

/* 状态点 */
.cs-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: 999px;
    font: 11px var(--mono);
    white-space: nowrap;
}
.cs-status.done { color: #087c60; background: #e8faf4; }
.cs-status.pending { color: #9c6b00; background: #fff4d9; }
.cs-status.failed { color: #b13939; background: #fff0f0; }

/* 提示框 */
.cs-alert {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
}
.cs-alert.error { border: 1px solid #ffc6c6; background: #fff5f5; color: #ae3a3a; }
.cs-alert.success { border: 1px solid #bfead9; background: #effbf6; color: #087c60; }
.cs-alert.info { border: 1px solid #cceee3; background: #f1fcf8; color: #148366; }
.cs-alert.warn { border: 1px solid #ffe3b3; background: #fffaf0; color: #9c6b00; }

/* 页面加载 */
.cs-route-loading {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(7px);
    animation: cs-fade-in .18s ease-out;
}
.cs-loader-card {
    width: 205px;
    padding: 20px 22px 18px;
    border: 1px solid #e6ece9;
    border-radius: 15px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 14px 44px rgba(0, 0, 0, .07);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #68736f;
    font-size: 13px;
}
.cs-loader-logo {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: #e7faf4;
    color: #169b79;
}
.cs-loader-track { width: 100%; height: 3px; border-radius: 99px; background: #e8efec; overflow: hidden; }
.cs-loader-track i {
    display: block;
    width: 45%;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #2ec9a4, #5ce5c7);
    animation: cs-load-slide .9s ease-in-out infinite;
}
.cs-spin { animation: cs-spin .9s linear infinite; }
@keyframes cs-spin { to { transform: rotate(360deg); } }
@keyframes cs-load-slide { 0% { transform: translateX(-115%); } 100% { transform: translateX(250%); } }
@keyframes cs-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* 空状态 */
.cs-empty {
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--muted);
    font-size: 13px;
}
.cs-empty.large { min-height: 220px; flex-direction: column; }
.cs-empty.large b { color: var(--fg); font-size: 16px; }

/* 通用工具类 */
.cs-muted { color: var(--muted); }
.cs-mono { font-family: var(--mono); }
.cs-mt-1 { margin-top: 8px; } .cs-mt-2 { margin-top: 16px; } .cs-mt-3 { margin-top: 24px; }
.cs-mb-2 { margin-bottom: 16px; }
.cs-hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
