/* ============================================================
   文件分享下载平台 — Preline 风格样式
   ============================================================ */
:root {
    --bg: #f9fafb;          /* gray-50  */
    --card: #ffffff;
    --border: #e5e7eb;      /* gray-200 */
    --border-strong: #d1d5db;
    --text: #111827;        /* gray-900 */
    --muted: #6b7280;       /* gray-500 */
    --primary: #2563eb;     /* blue-600 */
    --primary-hover: #1d4ed8;
    --primary-fg: #ffffff;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --soft: #f3f4f6;        /* gray-100 */
    --input-bg: #ffffff;
    --ring: rgba(37, 99, 235, .25);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 10px 15px -3px rgba(16, 24, 40, .08), 0 4px 6px -4px rgba(16, 24, 40, .05);
    --radius: 12px;
    --radius-sm: 8px;
}

:root[data-theme="dark"] {
    --bg: #0b0f17;
    --card: #111827;        /* gray-900 */
    --border: #1f2937;      /* gray-800 */
    --border-strong: #374151;
    --text: #f3f4f6;
    --muted: #9ca3af;       /* gray-400 */
    --primary: #3b82f6;     /* blue-500 */
    --primary-hover: #60a5fa;
    --primary-fg: #ffffff;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --soft: #1f2937;
    --input-bg: #1f2937;
    --ring: rgba(59, 130, 246, .4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease;
}

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

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---------- 顶栏 ---------- */
.topbar {
    background: var(--card); /* 回退 */
    background: color-mix(in srgb, var(--card) 85%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 600; font-size: 17px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { color: var(--text); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
    color: var(--muted); font-size: 14px; font-weight: 500;
    padding: 7px 12px; border-radius: var(--radius-sm); transition: .15s;
}
.nav a:hover { color: var(--text); background: var(--soft); }

main.container { padding-top: 32px; padding-bottom: 64px; min-height: calc(100vh - 200px); }

/* ---------- 页头 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -.02em; }

/* ---------- 表单控件（Preline 风）---------- */
input, textarea, button, select { font: inherit; }

.search { display: flex; gap: 8px; }
.search input {
    padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    width: 240px; background: var(--input-bg); color: var(--text); transition: .15s;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

/* 按钮基类 */
.btn-primary, .btn-danger, .search button {
    border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 14px; font-weight: 500; padding: 9px 16px; transition: .15s;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary, .search button { background: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow-sm); }
.btn-primary:hover, .search button:hover { background: var(--primary-hover); color: #fff; }
.btn-primary:focus-visible, .search button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }

/* ---------- 排序条 ---------- */
.sortbar { margin-bottom: 20px; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.sortbar a { color: var(--muted); padding: 5px 10px; border-radius: 999px; transition: .15s; }
.sortbar a:hover { background: var(--soft); color: var(--text); }
.sortbar a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 600; }

/* ---------- 文件网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: flex; gap: 14px; color: var(--text);
    box-shadow: var(--shadow-sm); transition: .18s ease;
}
.card:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); transform: translateY(-2px); }
.card-icon { font-size: 34px; line-height: 1; }
.card-body { min-width: 0; flex: 1; }
.card-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.card-stats { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }

/* ---------- 详情/统计通用 ---------- */
.detail { display: flex; gap: 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.detail-icon { font-size: 64px; }
.detail-main { flex: 1; min-width: 260px; }
.detail-main h1 { margin: 0 0 8px; font-size: 22px; word-break: break-all; }
.detail-meta { color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.detail-desc { margin: 16px 0; color: var(--text); }
.detail-stats { display: flex; gap: 28px; margin: 22px 0; }
.stat { text-align: center; }
.stat .num { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .label { font-size: 13px; color: var(--muted); }

/* ---------- 分享链接框 ---------- */
.share { margin-top: 20px; }
.share label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.share-box { display: flex; gap: 8px; }
.share-box input {
    flex: 1; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--soft); color: var(--text); font-size: 13px;
}
.share-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.share-box button {
    padding: 9px 16px; border: 1px solid var(--border); background: var(--card); color: var(--text);
    border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 500; transition: .15s;
}
.share-box button:hover { background: var(--soft); border-color: var(--border-strong); }

.back-link { margin-top: 20px; }

/* ---------- 上传表单 ---------- */
.upload-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; max-width: 640px; box-shadow: var(--shadow-sm); }
.filedrop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 44px 20px;
    cursor: pointer; text-align: center; transition: .15s; margin-bottom: 18px; background: var(--soft);
}
.filedrop.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--card)); }
.filedrop input[type=file] { display: none; }
.filedrop-text { color: var(--muted); }
.filedrop-name { color: var(--primary); font-weight: 600; margin-top: 8px; }
.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-size: 14px; margin-bottom: 6px; color: var(--text); font-weight: 500; }
.field input, .field textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--input-bg); color: var(--text); transition: .15s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.form-hint { font-size: 12px; color: var(--muted); margin-bottom: 18px; word-break: break-all; }

/* ---------- 选项卡（分段控件）---------- */
.tabs { display: inline-flex; gap: 4px; margin-bottom: 18px; padding: 4px; background: var(--soft); border-radius: 10px; }
.tab {
    padding: 7px 16px; border: none; background: transparent; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted); transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 进度条 ---------- */
.progress-wrap { margin-top: 18px; }
.progress { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .15s ease; }
.progress-bar.indeterminate { width: 40%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.progress-text { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- 提示 ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert.error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.alert.success { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
:root[data-theme="dark"] .alert.error { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .35); color: #fca5a5; }
:root[data-theme="dark"] .alert.success { background: rgba(74, 222, 128, .12); border-color: rgba(74, 222, 128, .35); color: #86efac; }
.empty { color: var(--muted); text-align: center; padding: 48px; }

/* ---------- 统计看板 ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow-sm); }
.metric-num { font-size: 26px; font-weight: 700; color: var(--primary); letter-spacing: -.02em; }
.metric-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.panel h2 { margin: 0 0 18px; font-size: 17px; font-weight: 600; }

.chart { display: flex; align-items: flex-end; gap: 14px; height: 180px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; width: 100%; justify-content: center; }
.bar { width: 30%; min-height: 2px; border-radius: 4px 4px 0 0; }
.bar.pv { background: var(--primary); }
.bar.dl { background: #10b981; }
.chart-label { font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend { margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 6px 0 14px; }
.legend .dot.pv { background: var(--primary); }
.legend .dot.dl { background: #10b981; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr { transition: .12s; }
.table tbody tr:hover { background: var(--soft); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.tag-download { background: rgba(16, 185, 129, .14); color: #059669; }
.tag-click { background: rgba(234, 88, 12, .14); color: #ea580c; }
.tag-site_pv { background: rgba(37, 99, 235, .14); color: #2563eb; }
.tag-file_view { background: rgba(124, 58, 237, .14); color: #7c3aed; }

/* ---------- 页脚 ---------- */
.footer { border-top: 1px solid var(--border); background: var(--card); padding: 24px 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- 主题切换按钮 ---------- */
.theme-btn {
    border: 1px solid var(--border); background: var(--card); color: var(--text);
    width: 38px; height: 38px; border-radius: var(--radius-sm); cursor: pointer; font-size: 16px;
    line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: .15s;
}
.theme-btn:hover { background: var(--soft); border-color: var(--border-strong); }
.theme-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.theme-fixed { position: fixed; top: 18px; right: 18px; z-index: 40; box-shadow: var(--shadow); }

/* ---------- 极简公开下载页 ---------- */
.dl-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.dl-owner-bar { width: 100%; max-width: 480px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 14px; }
.dl-owner-tag { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.dl-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 20px;
    padding: 44px 36px; max-width: 480px; width: 100%; text-align: center; box-shadow: var(--shadow-lg);
}
.dl-icon { font-size: 72px; line-height: 1; margin-bottom: 14px; }
.dl-card h1 { font-size: 20px; font-weight: 600; margin: 0 0 8px; word-break: break-all; letter-spacing: -.01em; }
.dl-meta { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.dl-desc { color: var(--text); font-size: 14px; margin: 0 0 22px; text-align: left; background: var(--soft); border-radius: var(--radius-sm); padding: 14px; }
.dl-btn { display: inline-block; margin-top: 8px; }
.dl-stats { display: flex; gap: 28px; justify-content: center; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }

@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .nav a { padding: 7px 9px; }
}
