:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app-container { max-width: 1200px; margin: 0 auto; padding: 40px 24px 80px; }

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand-logo {
  width: 44px;
  height: 44px;
  color: var(--primary);
  display: grid;
  place-items: center;
  background: var(--primary-light);
  border-radius: var(--radius-md);
}

.brand-logo svg { width: 26px; height: 26px; }

.app-header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }

.subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* Toolbar */
.toolbar { margin-bottom: 24px; }

.stat { font-size: 0.95rem; color: var(--text-secondary); }
.stat strong { color: var(--text); font-weight: 700; }

/* Page list */
.page-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
}

.empty-state.show { display: flex; }

.empty-illustration {
  width: 80px;
  height: 80px;
  color: var(--text-tertiary);
  opacity: 0.5;
  margin-bottom: 20px;
}

.empty-state h3 { font-size: 1.15rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.95rem; }

/* Card */
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.page-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-name {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
  color: var(--text);
}

.card-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.card-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition);
}

.card-edit svg { width: 16px; height: 16px; }

.card-edit:hover { background: var(--primary-light); color: var(--primary); }

.card-thumb {
  margin: -20px -20px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--border-light);
}

.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-thumb-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  color: var(--primary);
}
.card-file-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.card-file-icon svg { width: 38px; height: 38px; }
.card-file-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-qr {
  align-self: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
  line-height: 0;
  box-shadow: var(--shadow-sm);
}

.card-qr canvas { width: 140px; height: 140px; border-radius: 0; display: block; }

.card-link {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-actions .act {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 4px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.card-actions .act svg { width: 15px; height: 15px; }

.card-actions .act:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.card-actions .act.danger:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }

.card-expire {
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 500;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 11px 22px;
  background: var(--text);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Responsive */
@media (max-width: 640px) {
  .app-container { padding: 24px 16px 48px; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .app-header h1 { font-size: 1.4rem; }
  .page-list { grid-template-columns: 1fr; }
}

/* 新建页面·类型选择弹窗 */
.mode-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.mode-modal[hidden] { display: none; }
.mode-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px); }
.mode-modal-box { position: relative; width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-lg); animation: modePop 0.18s ease; }
@keyframes modePop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.mode-modal-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 20px; text-align: center; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-opt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 24px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--bg); text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
.mode-opt:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow); }
.mode-opt-icon { width: 48px; height: 48px; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.mode-opt-icon svg { width: 40px; height: 40px; }
.mode-opt-title { font-size: 1.05rem; font-weight: 700; }
.mode-opt-desc { font-size: 0.8rem; color: var(--text-tertiary); line-height: 1.4; }
.mode-cancel { display: block; width: 100%; margin-top: 20px; padding: 11px; border: 0; border-radius: var(--radius-sm); background: var(--bg); color: var(--text-secondary); font-size: 0.95rem; cursor: pointer; transition: background 0.15s; }
.mode-cancel:hover { background: var(--border-light); }

@media (max-width: 520px) {
  .mode-options { grid-template-columns: 1fr; }
}
