:root {
  --bg: #0b0f17;
  --bg2: #111827;
  --card: #151d2b;
  --card-hover: #1a2434;
  --line: #23283a;
  --text: #e6ebf5;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent2: #6ee7b7;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2a4a 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 0%, #1e3a2f 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.login-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
}
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%;
  background: #0d1320;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,140,255,0.18);
}
textarea { resize: vertical; min-height: 160px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.5; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  transition: transform .06s, background .15s, opacity .15s;
}
button:active { transform: translateY(1px); }
.btn {
  background: var(--accent);
  color: #06111f;
  font-weight: 700;
  padding: 11px 16px;
  width: 100%;
}
.btn:hover { background: #6ea0ff; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 9px 14px;
  font-weight: 600;
}
.btn-ghost:hover { background: var(--card-hover); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255,107,107,0.4); padding: 9px 14px; font-weight: 600; }
.btn-danger:hover { background: rgba(255,107,107,0.1); }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- 主体 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 26px;
  background: rgba(11,15,23,0.75);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .3px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #7fe3ff, var(--accent));
  box-shadow: 0 0 14px rgba(79,140,255,.9);
}
.brand small { color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }

.container { max-width: 1080px; margin: 0 auto; padding: 26px; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .count { color: var(--muted); font-size: 13px; }
.search { max-width: 240px; margin-left: auto; }

.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: border-color .15s, background .15s, opacity .15s;
}
.card:hover { border-color: #2f3a52; background: var(--card-hover); }
.card.off { opacity: 0.62; }
.card .meta { flex: 1; min-width: 0; }
.card .name { font-size: 15px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.card .name .txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .name .ver {
  font-size: 11px; font-weight: 600; color: var(--accent2);
  border: 1px solid rgba(110,231,183,0.35); border-radius: 999px; padding: 1px 8px;
}
.card .desc { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .id { color: #5b6478; font-size: 11.5px; font-family: ui-monospace, Consolas, monospace; margin-top: 4px; }
.card .actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); background: var(--card-hover); }
.icon-btn svg { width: 16px; height: 16px; }

/* 开关 */
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #2a3145; border-radius: 999px;
  transition: background .2s;
}
.slider::before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 4px; top: 4px;
  background: #cfd6e6; border-radius: 50%;
  transition: transform .2s, background .2s;
}
.switch input:checked + .slider { background: linear-gradient(90deg, #36c98a, #4f8cff); }
.switch input:checked + .slider::before { transform: translateX(22px); background: #fff; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(3,6,12,0.68);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1b2436; color: #fff;
  border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 云端加载器提示 ---------- */
.loader-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, rgba(79,123,255,.10), rgba(79,123,255,.02)); }
.loader-info { flex: 1 1 260px; min-width: 0; }
.loader-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.loader-title .tag { font-size: 11px; font-weight: 700; color: #06111f; background: var(--accent2); padding: 1px 8px; border-radius: 999px; }
.loader-desc { color: var(--muted); font-size: 13px; line-height: 1.6; }
.loader-actions { display: flex; gap: 10px; align-items: center; }
.loader-actions .btn, .loader-actions .btn-ghost { width: auto; }

@media (max-width: 720px) {
  .loader-box { padding: 12px; gap: 10px; }
  .loader-actions { width: 100%; }
  .loader-actions .btn, .loader-actions .btn-ghost { flex: 1 1 0; }
}

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ---------- 手机 / H5 自适应（紧凑，尽量多显示脚本） ---------- */
@media (max-width: 720px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .who { display: none; }
  .brand { font-size: 14px; }
  .container { padding: 10px 10px calc(24px + env(safe-area-inset-bottom)); }

  .page-head { gap: 8px; margin-bottom: 10px; }
  .page-head h2 { font-size: 17px; }
  .page-head .count { font-size: 12px; }
  .page-head .search { flex: 1 1 100%; width: 100%; max-width: none; margin-left: 0; padding: 9px 12px; }
  .page-head #installAllBtn,
  .page-head #addBtn { flex: 1 1 0; width: auto; padding: 10px 8px; }

  .grid { gap: 8px; }

  /* 紧凑卡片：名称一行、操作一行，隐藏 ID/描述，一屏能看到更多 */
  .card { flex-wrap: wrap; padding: 8px 10px; gap: 4px 6px; border-radius: 12px; align-items: center; }
  .card .meta { flex: 1 1 100%; min-width: 0; }
  .card .name { font-size: 13.5px; margin-bottom: 0; gap: 6px; }
  .card .name .ver { font-size: 10px; padding: 0 6px; }
  .card .desc, .card .id { display: none; }
  .card .actions { width: 100%; flex: 1 1 100%; justify-content: flex-end; gap: 6px; }
  .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
  .icon-btn svg { width: 15px; height: 15px; }
  .switch { width: 44px; height: 25px; }
  .slider::before { height: 19px; width: 19px; left: 3px; top: 3px; }
  .switch input:checked + .slider::before { transform: translateX(19px); }

  .row2 { grid-template-columns: 1fr; gap: 0; }
  .modal-mask { padding: 12px; align-items: flex-start; overflow-y: auto; }
  .modal { padding: 20px 16px; border-radius: 16px; max-height: 92vh; overflow-y: auto; }
  .modal textarea { min-height: 130px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn,
  .modal-actions .btn-ghost { width: 100%; padding: 12px 14px; }

  .login-wrap { padding: 16px; }
  .login-card { padding: 22px 20px; }
}

/* 极小屏（如 iPhone SE 竖屏） */
@media (max-width: 380px) {
  .card .name { font-size: 14px; }
  .page-head h2 { font-size: 18px; }
  .btn-ghost, .btn { font-size: 13.5px; }
}

/* 触屏设备：加大可点击区域，去掉 hover 位移 */
@media (hover: none) {
  .card:hover { border-color: var(--line); background: transparent; }
  button:active { transform: none; }
  input[type="text"], input[type="password"], input[type="search"], textarea { font-size: 16px; }
}
