:root {
  --bg-0: #070b16;
  --bg-1: #0b1224;
  --panel: rgba(148, 184, 255, .055);
  --panel-solid: #0e1730;
  --border: rgba(122, 162, 247, .16);
  --border-hi: rgba(56, 199, 255, .45);
  --text: #e6eefc;
  --text-sub: #8fa3c4;
  --text-dim: #5a6b8c;
  --cyan: #38d9f9;
  --blue: #4f7cff;
  --grad: linear-gradient(120deg, #38d9f9, #4f7cff 60%, #7c5cff);
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 10px 34px rgba(2, 6, 18, .55);
  --glow: 0 0 22px rgba(56, 217, 249, .28);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(79, 124, 255, .16), transparent 60%),
    radial-gradient(700px 420px at -10% 20%, rgba(56, 217, 249, .10), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* 科技网格底纹 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(122, 162, 247, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 162, 247, .05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.25) 45%, rgba(0,0,0,.7));
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.25) 45%, rgba(0,0,0,.7));
}

header, main, footer { position: relative; z-index: 1; }

/* ============ 顶部 ============ */
.hero {
  background: linear-gradient(180deg, rgba(13, 22, 44, .92), rgba(10, 16, 34, .78));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  padding: 30px 24px;
  box-shadow: 0 10px 40px rgba(2, 6, 18, .5);
}
.hero-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 22px; flex-wrap: wrap;
}
.hero-brand { display: flex; align-items: center; gap: 16px; }
.hero-logo {
  width: 62px; height: 62px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(122, 162, 247, .35), 0 0 26px rgba(56, 217, 249, .35);
}
.hero-text h1 {
  font-size: 27px; font-weight: 700; letter-spacing: 1px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-text p { margin-top: 5px; font-size: 13.5px; color: var(--text-sub); letter-spacing: 2px; }
.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(11, 20, 40, .7);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  min-width: 250px;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within { border-color: var(--border-hi); box-shadow: var(--glow); }
.search-box .search-icon { opacity: .7; }
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text);
  font-size: 14px; width: 100%;
}
.search-box input::placeholder { color: var(--text-dim); }

/* ============ 主体 ============ */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px 50px; width: 100%; flex: 1; }

.category-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font-size: 14px; color: var(--text-sub); transition: all .18s;
  backdrop-filter: blur(6px);
}
.cat-chip:hover { border-color: var(--border-hi); color: var(--cyan); }
.cat-chip.active {
  background: linear-gradient(120deg, rgba(56, 217, 249, .18), rgba(79, 124, 255, .22));
  border-color: var(--border-hi); color: #dff6ff;
  box-shadow: var(--glow);
}
.cat-count {
  background: rgba(122, 162, 247, .14); border-radius: 999px;
  padding: 1px 8px; font-size: 12px; font-weight: 600;
}
.cat-chip.active .cat-count { background: rgba(56, 217, 249, .25); color: #eafcff; }

.tools-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.tool-card {
  position: relative;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; text-decoration: none;
  color: var(--text); display: flex; align-items: center; gap: 14px;
  backdrop-filter: blur(8px);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.tool-card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(56,217,249,.07), rgba(124,92,255,.07));
  opacity: 0; transition: opacity .18s; pointer-events: none;
}
.tool-card:hover { transform: translateY(-3px); border-color: var(--border-hi); box-shadow: var(--glow), var(--shadow); }
.tool-card:hover::after { opacity: 1; }
.tool-icon {
  width: 52px; height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: linear-gradient(135deg, rgba(56,217,249,.14), rgba(79,124,255,.16));
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tool-info { flex: 1; min-width: 0; }
.tool-name {
  font-size: 15.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 64px;
}
.tool-desc {
  font-size: 12.5px; color: var(--text-sub); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tool-cat {
  position: absolute; top: 10px; right: 12px;
  font-size: 11px; color: #7fd8f7; background: rgba(56, 217, 249, .10);
  border: 1px solid rgba(56, 217, 249, .22);
  padding: 2px 8px; border-radius: 6px;
}

.empty-state { text-align: center; padding: 70px 20px; color: var(--text-sub); }
.empty-icon { font-size: 52px; margin-bottom: 12px; }

/* ============ 访客提示 ============ */
.guest-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px dashed rgba(56, 217, 249, .35); border-radius: 12px;
  background: rgba(56, 217, 249, .06);
  padding: 12px 16px; margin-bottom: 20px;
  font-size: 13.5px; color: var(--text-sub);
}
.guest-login-link { color: var(--cyan); font-weight: 600; text-decoration: none; white-space: nowrap; }
.guest-login-link:hover { text-decoration: underline; }

/* ============ 文件柜 hover 预览 ============ */
.files-hover { position: relative; display: inline-flex; }
.files-popover {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 340px; max-width: 90vw;
  background: #0a1226; border: 1px solid rgba(122, 162, 247, .45);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .8), 0 0 0 1px rgba(56, 217, 249, .12);
  z-index: 60; overflow: hidden;
}
.files-popover-head {
  padding: 10px 14px; font-size: 13px; font-weight: 700; color: #e6f0ff;
  border-bottom: 1px solid rgba(122, 162, 247, .28); background: #0e1a36;
}
.files-popover-body { padding: 10px; max-height: 320px; overflow-y: auto; }
.files-popover-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 6px;
  background: #111c38; border: 1px solid rgba(122, 162, 247, .22);
}
.files-popover-item:last-child { margin-bottom: 0; }
.files-popover-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.files-popover-meta { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.files-popover-pwd { display: flex; gap: 6px; }
.files-popover-pwd input { flex: 1; }

/* ============ 底部 ============ */
.footer {
  text-align: center; padding: 26px 20px 30px;
  border-top: 1px solid rgba(122, 162, 247, .08);
}
.footer-copy { color: var(--text-dim); font-size: 12.5px; letter-spacing: 1px; }
.admin-link {
  display: inline-block; margin-top: 8px;
  color: var(--text-dim); font-size: 12px; text-decoration: none;
  letter-spacing: 2px; opacity: .55; transition: all .2s;
}
.admin-link:hover { color: var(--cyan); opacity: 1; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 9px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .18s; line-height: 1.2;
}
.btn-primary {
  background: linear-gradient(120deg, #2fb9dd, #4f7cff);
  color: #fff; box-shadow: 0 4px 16px rgba(56, 174, 249, .3);
}
.btn-primary:hover { filter: brightness(1.12); box-shadow: 0 4px 22px rgba(56, 174, 249, .45); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-sub); }
.btn-ghost:hover { border-color: var(--border-hi); color: var(--cyan); }
.btn-danger { background: transparent; border-color: rgba(255, 107, 107, .35); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 107, 107, .12); border-color: var(--danger); }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }

/* ============ 表单 ============ */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; }
input, select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; outline: none;
  background: rgba(8, 14, 30, .75); color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}
input::placeholder { color: var(--text-dim); }
input:focus, select:focus { border-color: var(--border-hi); box-shadow: var(--glow); }
select option { background: var(--panel-solid); color: var(--text); }

/* ============ 登录 ============ */
.admin-body { align-items: center; justify-content: center; }
.login-wrap {
  width: 100%; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: rgba(13, 22, 44, .82); border: 1px solid var(--border);
  border-radius: 18px; padding: 36px 34px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow), var(--glow);
  backdrop-filter: blur(12px);
}
.login-logo {
  display: block; margin: 0 auto; width: 78px; height: 78px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(122, 162, 247, .35), 0 0 30px rgba(56, 217, 249, .35);
}
.login-card h2 { text-align: center; margin: 16px 0 4px; font-size: 21px; letter-spacing: 1px; }
.login-sub { text-align: center; color: var(--text-sub); font-size: 13.5px; margin-bottom: 22px; }
.login-card label { margin-top: 14px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 12px; }
.login-card .btn { margin-top: 6px; }
.back-link { display: block; text-align: center; margin-top: 16px; color: var(--text-dim); font-size: 13.5px; text-decoration: none; }
.back-link:hover { color: var(--cyan); }

/* ============ 后台 ============ */
.admin-wrap { width: 100%; min-height: 100vh; }
.admin-header {
  background: linear-gradient(180deg, rgba(13, 22, 44, .92), rgba(10, 16, 34, .78));
  border-bottom: 1px solid var(--border);
  color: var(--text); padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.admin-header-brand { display: flex; align-items: center; gap: 14px; }
.admin-header-logo { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(122,162,247,.3), 0 0 16px rgba(56,217,249,.3); }
.admin-header h1 { font-size: 19px; letter-spacing: .5px; }
.admin-header p { font-size: 12.5px; color: var(--text-sub); margin-top: 3px; }
.admin-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.admin-main { max-width: 1000px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.panel-title { font-size: 15.5px; font-weight: 700; margin-bottom: 16px; letter-spacing: .5px; color: #cfe0ff; }
.panel-title::before { content: "▍"; color: var(--cyan); margin-right: 4px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head .panel-title { margin-bottom: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

.cat-add-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cat-add-row input:first-child { flex: 1; min-width: 200px; }

.cat-list { display: flex; flex-wrap: wrap; gap: 10px; }
.cat-item {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
  background: rgba(8, 14, 30, .55);
}
.cat-item-icon { font-size: 18px; }
.cat-item-name { font-size: 14px; font-weight: 600; }

.tool-table-wrap { overflow-x: auto; }
.tool-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tool-table th, .tool-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid rgba(122, 162, 247, .1); vertical-align: middle; }
.tool-table th { color: var(--text-dim); font-size: 12.5px; font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: 1px; }
.tool-table tbody tr:hover { background: rgba(56, 217, 249, .045); }
.tool-icon-cell { font-size: 22px; }
.tool-name-cell { font-weight: 600; }
.tool-desc-sm { font-size: 12px; color: var(--text-sub); font-weight: 400; margin-top: 2px; }
.tool-url-cell { max-width: 220px; }
.tool-url-cell a { color: var(--cyan); text-decoration: none; word-break: break-all; font-size: 12.5px; }
.tool-url-cell a:hover { text-decoration: underline; }
.tool-ops { display: flex; gap: 6px; white-space: nowrap; }
.muted { color: var(--text-dim); font-size: 12.5px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(2, 6, 18, .68);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px; width: 100%; max-width: 520px;
  box-shadow: var(--shadow), var(--glow);
}
.modal-sm { max-width: 400px; }
.modal h3 { font-size: 18px; margin-bottom: 18px; color: #cfe0ff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ============ 文件下载 ============ */
.file-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.file-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  background: rgba(8, 14, 30, .55);
}
.file-item-info { flex: 1; min-width: 0; }
.file-item-name { font-size: 14px; font-weight: 600; word-break: break-all; }
.file-item-meta { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
input[type="file"] { padding: 8px; cursor: pointer; color: var(--text-sub); }

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .hero-inner { flex-direction: column; align-items: stretch; }
  .hero-actions { justify-content: stretch; }
  .search-box { flex: 1; min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-header { flex-direction: column; align-items: flex-start; }
}
