:root {
  --bg: #f4f5fa;
  --card: #ffffff;
  --text: #1a1d29;
  --muted: #7a7f96;
  --line: #e6e8f0;
  --primary: #5b5ce2;
  --primary-dark: #4647c9;
  --primary-soft: #eef0ff;
  --gold: #f5a623;
  --danger: #e5484d;
  --green: #2fa860;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(24, 28, 50, .06), 0 8px 24px -12px rgba(24, 28, 50, .12);
  --shadow-lg: 0 24px 64px -16px rgba(24, 28, 50, .25);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- 导航栏 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 0 28px; height: 64px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-logo {
  display: flex; align-items: center; gap: 9px;
  font-size: 21px; font-weight: 800; letter-spacing: .5px;
  color: var(--primary); white-space: nowrap;
}
.nav-logo em { font-style: normal; color: var(--text); }
.nav-search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 10px; padding: 0 14px; height: 40px;
  color: var(--muted); transition: .18s;
}
.nav-search:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.nav-search input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: 10px;
  height: 40px; padding: 0 18px;
  font-size: 14px; font-weight: 600;
  transition: .18s;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px -4px rgba(91, 92, 226, .5); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: #fdecec; color: var(--danger); }
.btn-danger:hover { background: #fad4d6; }
.btn-lite { background: var(--bg); color: var(--text); }
.btn-lite:hover { background: var(--line); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6a6bf0, #9d7bf5);
  color: #fff; cursor: pointer; flex-shrink: 0;
  transition: .18s;
}
.avatar:hover { transform: scale(1.06); }
.avatar.logged::after {
  content: ''; position: absolute; transform: translate(13px, 13px);
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); border: 2px solid #fff;
}

/* ---------- 主体 ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 28px 28px 80px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 800; }
.page-head .count { color: var(--muted); font-size: 13px; }

/* ---------- 应用库布局 ---------- */
.lib-wrap { display: grid; grid-template-columns: 208px 1fr; gap: 24px; align-items: start; }
.side {
  position: sticky; top: 84px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px;
}
.side-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 9px;
  font-size: 14px; cursor: pointer; color: var(--text);
  transition: .15s; user-select: none;
}
.side-item:hover { background: var(--bg); }
.side-item.on { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.side-item em {
  margin-left: auto; font-style: normal; font-size: 12px;
  color: var(--muted); background: var(--bg);
  padding: 1px 8px; border-radius: 10px;
}
.side-item.on em { background: #fff; color: var(--primary); }
.side-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.side-new {
  color: var(--primary); font-weight: 600; justify-content: center;
  border: 1.5px dashed #d0d4f7; margin-top: 6px; font-size: 13px;
}
.side-new:hover { background: var(--primary-soft); }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border-radius: 12px; padding: 10px 14px;
  margin-bottom: 16px; box-shadow: var(--shadow); font-size: 13.5px;
}
.card.editing { user-select: none; }
.card.sel { outline: 2.5px solid var(--primary); }
.card.sel::after {
  content: '✓'; position: absolute; top: -9px; left: -9px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.cat-sel {
  height: 26px; border-radius: 7px; border: 1.5px solid var(--line);
  background: #fff; font-size: 12.5px; padding: 0 6px; outline: none;
  color: var(--text); cursor: pointer; font-family: inherit;
}
.cat-sel:focus { border-color: var(--primary); }
@media (max-width: 900px) {
  .lib-wrap { grid-template-columns: 1fr; gap: 14px; }
  .side { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .side-item { white-space: nowrap; padding: 8px 12px; flex-shrink: 0; }
  .side-item em { display: none; }
  .side-sep { display: none; }
}

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  position: relative;
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  cursor: pointer; transition: .2s;
  border: 1px solid transparent;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #dcdcf8; }
.card-top { display: flex; gap: 14px; align-items: center; }
.app-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--primary-soft); object-fit: cover; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: var(--primary);
  overflow: hidden;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-info { min-width: 0; }
.card-info .name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-info .pkg { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.card-meta { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.tag {
  font-size: 12px; padding: 3px 9px; border-radius: 6px;
  background: var(--bg); color: var(--muted); font-weight: 500;
}
.tag.ver { background: var(--primary-soft); color: var(--primary); }
.tag.lock { background: #fff3e2; color: #c77e14; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 12px; }
.star {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: #c9cddb; padding: 4px;
  transition: .15s;
}
.star:hover { transform: scale(1.2); color: var(--gold); }
.star.on { color: var(--gold); }

.empty {
  text-align: center; padding: 90px 0; color: var(--muted);
}
.empty .big { font-size: 52px; margin-bottom: 14px; }
.empty p { margin-bottom: 18px; }

/* ---------- 详情页 ---------- */
.detail-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .detail-wrap { grid-template-columns: 1fr; } }
.panel {
  background: var(--card); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 22px; }
.panel h3 { font-size: 15px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.back-link:hover { color: var(--primary); }

.detail-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.detail-head .app-icon { width: 84px; height: 84px; border-radius: 20px; font-size: 36px; }
.detail-head h2 { font-size: 24px; font-weight: 800; }
.detail-head .pkg { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.detail-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.stat-row { display: flex; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px; background: var(--bg);
  border-radius: 12px; padding: 14px 16px;
}
.stat .num { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 3px; }

.share-item { margin-bottom: 18px; }
.share-item .lbl { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input {
  flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 0 12px; height: 38px; font-size: 13px; color: var(--text);
  background: var(--bg); outline: none;
}
.copy-row .btn { height: 38px; padding: 0 14px; flex-shrink: 0; }
.qr-box { text-align: center; padding: 10px 0 4px; }
.qr-box img {
  width: 190px; height: 190px; border-radius: 12px;
  border: 1px solid var(--line); padding: 8px; background: #fff;
}
.qr-box .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.code-chip {
  font-size: 26px; font-weight: 800; letter-spacing: 6px;
  color: var(--primary); background: var(--primary-soft);
  padding: 12px 0; border-radius: 10px; text-align: center;
  font-family: 'Consolas', monospace; cursor: pointer; user-select: all;
}

.att-list { display: flex; flex-direction: column; gap: 8px; }
.att-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px;
}
.att-ic { font-size: 18px; flex-shrink: 0; }
.att-name {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-weight: 600;
}
.att-size { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.att-btn { height: 30px; padding: 0 12px; font-size: 12.5px; flex-shrink: 0; }
@media (max-width: 720px) {
  .att-row { flex-wrap: wrap; }
  .att-name { flex-basis: 100%; white-space: normal; word-break: break-all; }
}

.vfile {
  font-size: 11.5px; color: var(--muted); margin-top: 3px;
  word-break: break-all; max-width: 360px; font-weight: 400;
}
.latest-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  color: #0d8050; background: #e3f7ed; border-radius: 6px;
  padding: 1px 7px; margin-left: 4px; vertical-align: middle;
}
.hash-chip {
  display: inline-block; font-size: 11px; font-weight: 500;
  font-family: 'Consolas', monospace; color: var(--primary-dark);
  background: var(--primary-soft); border-radius: 6px;
  padding: 1px 7px; margin-left: 4px; cursor: pointer; vertical-align: middle;
}
.hash-chip:hover { background: #dfe3ff; }
.vnote {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: #92400e; background: #fef3c7; border-radius: 6px;
  padding: 1px 7px; margin-left: 4px; vertical-align: middle;
}
.vnote.add {
  color: var(--muted); background: var(--bg); cursor: pointer;
  border: 1px dashed var(--line); font-weight: 500;
}
.vnote.add:hover { color: var(--primary); border-color: var(--primary); }
.rename-btn {
  background: none; border: none; font-size: 14px; padding: 2px 4px;
  border-radius: 6px; vertical-align: middle; opacity: .55; transition: .15s;
}
.rename-btn:hover { opacity: 1; background: var(--bg); }

.desc-ipt {
  width: 100%; min-height: 110px; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; font-family: inherit; resize: vertical;
  outline: none; background: var(--bg); transition: .15s; color: var(--text); line-height: 1.6;
}
.desc-ipt:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.desc-text { font-size: 14px; line-height: 1.9; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.dl-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--primary-soft); border: 1px solid #dfe2ff;
  border-radius: 8px; padding: 2px 4px 2px 10px; margin: 2px 0;
  vertical-align: middle;
}
.dl-chip code {
  font-size: 12.5px; color: var(--primary-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 320px;
}
.copy-mini {
  flex-shrink: 0; border: none; background: var(--primary); color: #fff;
  font-size: 12px; padding: 4px 10px; border-radius: 6px; font-weight: 600;
}
.copy-mini:hover { background: var(--primary-dark); }
@media (max-width: 720px) { .dl-chip code { max-width: 180px; } }

.ver-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ver-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ver-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.ver-table tr:last-child td { border-bottom: none; }
.ver-table .icon-btn {
  background: none; border: none; color: var(--muted); padding: 5px;
  border-radius: 7px; display: inline-flex;
}
.ver-table .icon-btn:hover { background: var(--bg); color: var(--primary); }
.ver-table .icon-btn.del:hover { color: var(--danger); background: #fdecec; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 22, 40, .45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; padding: 28px;
  animation: pop .22s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes pop { from { transform: scale(.94) translateY(10px); opacity: 0; } }
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.modal-close {
  float: right; background: var(--bg); border: none; width: 32px; height: 32px;
  border-radius: 9px; font-size: 16px; color: var(--muted);
}
.modal-close:hover { background: var(--line); }

.drop-zone {
  position: relative; display: block;
  border: 2px dashed #c8cbe8; border-radius: 14px;
  padding: 44px 20px; text-align: center; color: var(--muted);
  transition: .18s; cursor: pointer; background: var(--bg);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.drop-zone .di { font-size: 40px; margin-bottom: 10px; }
.drop-zone strong { color: var(--text); }
.drop-zone.over strong { color: var(--primary); }

.up-progress { margin-top: 6px; }
.up-file { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 12px; }
.up-file .fn { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), #9d7bf5);
  border-radius: 6px; transition: width .2s;
}
.up-status { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.field input {
  width: 100%; height: 44px; border: 1.5px solid var(--line);
  border-radius: 10px; padding: 0 14px; font-size: 14px; outline: none;
  transition: .15s; background: var(--bg);
}
.field input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.form-err { color: var(--danger); font-size: 13px; margin: -6px 0 12px; min-height: 18px; }

/* ---------- 口令页 ---------- */
.code-page { max-width: 460px; margin: 7vh auto 0; text-align: center; }
.code-page .logo-big { font-size: 46px; margin-bottom: 10px; }
.code-page h1 { font-size: 24px; margin-bottom: 8px; }
.code-page .sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.code-input-row { display: flex; gap: 10px; }
.code-input-row input {
  flex: 1; height: 54px; border: 2px solid var(--line); border-radius: 13px;
  font-size: 22px; text-align: center; letter-spacing: 8px; font-weight: 700;
  text-transform: uppercase; outline: none; font-family: 'Consolas', monospace;
  transition: .15s;
}
.code-input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.code-input-row .btn { height: 54px; padding: 0 26px; border-radius: 13px; font-size: 15px; }
.redeem-result { margin-top: 28px; text-align: left; }
.redeem-card { display: flex; gap: 16px; align-items: center; }
.redeem-card .app-icon { width: 64px; height: 64px; border-radius: 16px; }
.redeem-card .meta { flex: 1; min-width: 0; }
.redeem-card .meta .nm { font-weight: 700; font-size: 16px; }
.redeem-card .meta .vs { color: var(--muted); font-size: 13px; margin-top: 3px; }
.dl-big { width: 100%; margin-top: 18px; height: 48px; font-size: 15px; border-radius: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: #23263b; color: #fff; padding: 11px 22px;
  border-radius: 11px; font-size: 14px; z-index: 200;
  box-shadow: var(--shadow-lg); animation: rise .25s;
}
.toast.err { background: var(--danger); }
@keyframes rise { from { transform: translate(-50%, 14px); opacity: 0; } }

.spin {
  width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: rot .7s linear infinite;
}
.spin.dark { border-color: #d8daf0; border-top-color: var(--primary); }
@keyframes rot { to { transform: rotate(360deg); } }

.loading-page { text-align: center; padding: 100px 0; color: var(--muted); }

@media (max-width: 720px) {
  .nav { padding: 0 14px; gap: 10px; }
  .nav-logo span { display: none; }
  .btn-primary span { display: none; }
  main { padding: 18px 14px 60px; }
  .detail-actions { margin-left: 0; }
  .detail-head .app-icon { width: 64px; height: 64px; border-radius: 16px; font-size: 28px; }
  .detail-head h2 { font-size: 20px; }
  .panel { padding: 18px 16px; }
  .code-input-row { flex-direction: column; }
  .code-input-row .btn { width: 100%; }
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) {
  .table-scroll .ver-table { min-width: 520px; }
}
