/* ============================
   Design Tokens
   ============================ */
:root {
  --bg: #0a0e1a;
  --bg-elev: #111726;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e6e9f2;
  --text-soft: #a5adbf;
  --text-mute: #6b7384;
  --accent: #7c9cff;
  --accent-2: #b794ff;
  --accent-3: #ff9ec4;
  --danger: #ff6b6b;
  --success: #5ae3a3;
  --warning: #ffd166;
  --gradient-1: linear-gradient(135deg, #7c9cff 0%, #b794ff 100%);
  --gradient-2: linear-gradient(135deg, #5ae3a3 0%, #7c9cff 100%);
  --gradient-3: linear-gradient(135deg, #ff9ec4 0%, #ffd166 100%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.18);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.32);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --surface: rgba(15, 23, 42, 0.04);
  --surface-strong: rgba(15, 23, 42, 0.08);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.12);
}

/* ============================
   Reset
   ============================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  min-height: 100vh;
  /* 移动端动态视口：避免手机地址栏遮挡底部内容 */
  min-height: 100dvh;
  position: relative;
  transition: background-color var(--transition), color var(--transition);
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: transparent; }
input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================
   Background Orbs
   ============================ */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
.bg-orb-1 { width: 480px; height: 480px; background: #7c9cff; top: -120px; left: -120px; }
.bg-orb-2 { width: 520px; height: 520px; background: #b794ff; top: 40%; right: -160px; }
.bg-orb-3 { width: 380px; height: 380px; background: #ff9ec4; bottom: -120px; left: 30%; opacity: 0.4; }

[data-theme="light"] .bg-orb { opacity: 0.28; }

/* ============================
   Layout
   ============================ */
.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  min-height: 100vh;
  /* 移动端动态视口 + 底部安全区（iPhone 横条等） */
  min-height: 100dvh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
}

/* ============================
   Header
   ============================ */
.header {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: var(--gradient-1);
  display: grid; place-items: center;
  font-size: 26px;
  box-shadow: var(--shadow);
}
.brand-title { font-size: 20px; font-weight: 700; letter-spacing: 0.2px; }
.brand-subtitle { font-size: 12px; color: var(--text-mute); letter-spacing: 0.5px; }

.header-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
  min-width: 280px;
}

/* Search Box */
.search-box {
  position: relative;
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
}
.search-box input {
  width: 100%;
  padding: 12px 56px 12px 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  font-size: 14px;
  transition: all var(--transition);
  backdrop-filter: blur(20px);
}
.search-box input:focus {
  background: var(--surface-strong);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.12);
}
.search-box input::placeholder { color: var(--text-mute); }
.search-icon {
  position: absolute;
  left: 14px;
  width: 18px; height: 18px;
  color: var(--text-mute);
  pointer-events: none;
}
.search-kbd {
  position: absolute;
  right: 12px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-mute);
  font-family: inherit;
  background: var(--surface);
}

/* Icon Buttons */
.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all var(--transition);
  backdrop-filter: blur(20px);
}
.icon-btn:hover { background: var(--surface-strong); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn.primary {
  background: var(--gradient-1);
  border-color: transparent;
  color: white;
}
.icon-btn.primary:hover { box-shadow: 0 8px 24px rgba(124, 156, 255, 0.36); }

/* Theme toggle visibility */
.icon-sun, .icon-moon { display: none; }
:root .icon-moon { display: block; }
:root .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: block; }

/* Category Bar */
.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.category-bar::-webkit-scrollbar { height: 6px; }
.category-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.cat-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px;
  white-space: nowrap;
  transition: all var(--transition);
  backdrop-filter: blur(20px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cat-chip:hover { background: var(--surface-strong); color: var(--text); }
.cat-chip.active {
  background: var(--gradient-1);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 16px rgba(124, 156, 255, 0.3);
}
.cat-chip .cat-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

/* ============================
   Main / Sections
   ============================ */
.main { flex: 1; padding-top: 16px; }

.sections { display: flex; flex-direction: column; gap: 36px; }

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border-strong), transparent);
}
.section-count {
  font-size: 12px;
  color: var(--text-mute);
  padding: 2px 10px;
  background: var(--surface);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* Card */
.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  backdrop-filter: blur(20px);
  cursor: pointer;
  overflow: hidden;
  animation: cardIn 400ms cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-1);
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: var(--radius);
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  background: var(--surface-strong);
}
.card:hover::before { opacity: 0.06; }

.card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 20px;
  font-weight: 600;
  flex-shrink: 0;
  background: var(--gradient-1);
  color: white;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}
.card-icon.color-2 { background: var(--gradient-2); }
.card-icon.color-3 { background: var(--gradient-3); }

.card-body { flex: 1; min-width: 0; }
.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-desc {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.card:hover .card-actions { opacity: 1; }
.card-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-mute);
  transition: all var(--transition);
}
.card-action-btn:hover { background: var(--surface-strong); color: var(--text); }
.card-action-btn.danger:hover { color: var(--danger); }
.card-action-btn svg { width: 14px; height: 14px; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-mute);
}
.empty-emoji { font-size: 56px; margin-bottom: 16px; }
.empty-text { font-size: 18px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ============================
   Footer
   ============================ */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 48px;
  color: var(--text-mute);
  font-size: 12px;
  flex-wrap: wrap;
}
.footer-dot { opacity: 0.5; }
.footer-btn {
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 4px;
  transition: all var(--transition);
}
.footer-btn:hover { color: var(--text); background: var(--surface); }

/* ============================
   Modal
   ============================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}
/* hidden 属性必须强制覆盖 .modal 的 display:grid,否则弹窗无法关闭 */
.modal[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: fadeIn 200ms ease;
}
[data-theme="light"] .modal-backdrop { background: rgba(15, 23, 42, 0.4); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 240ms cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 6px; }
.modal-body input, .modal-body select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  margin-bottom: 12px;
  transition: all var(--transition);
}
.modal-body input:focus, .modal-body select:focus {
  border-color: var(--accent);
  background: var(--surface-strong);
  box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.12);
}
.form-label {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 6px;
  font-weight: 500;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-ghost { background: var(--surface); color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-strong); color: var(--text); }
.btn-primary { background: var(--gradient-1); color: white; }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(124, 156, 255, 0.36); transform: translateY(-1px); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

/* ============================
   Toast
   ============================ */
.toast {
  position: fixed;
  bottom: 32px;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 240ms cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 720px) {
  .app {
    padding: 20px 16px 80px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  /* 移动端弱化背景光斑：部分手机浏览器对超大 blur + fixed 渲染异常，会盖住文字 */
  .bg-orb { opacity: 0.28; }
  .bg-orb-1 { width: 260px; height: 260px; top: -80px; left: -100px; }
  .bg-orb-2 { width: 300px; height: 300px; top: 30%; right: -140px; }
  .bg-orb-3 { width: 220px; height: 220px; bottom: -80px; left: 20%; opacity: 0.22; }
  .header-inner { gap: 12px; }
  .header-tools { width: 100%; min-width: 0; }
  .search-box { max-width: none; }
  .brand-subtitle { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .card { padding: 12px; }
  .card-icon { width: 36px; height: 36px; font-size: 16px; }
  .card-name { font-size: 13px; }
}

/* 触屏设备（手机/平板）没有 hover，操作按钮必须常显，否则无法编辑/删除 */
@media (hover: none), (max-width: 720px) {
  .card-actions { opacity: 1; }
}

@media (max-width: 480px) {
  .brand-text { display: none; }
  .grid { grid-template-columns: 1fr 1fr; }
  .section-header { gap: 8px; }
  .section-count { display: none; }
}

/* selection */
::selection { background: rgba(124, 156, 255, 0.32); color: var(--text); }