:root {
  --primary: #FF4D4F;
  --primary-dark: #D9363E;
  --secondary: #FF7A45;
  --bg: #0A0A0F;
  --surface: #16161E;
  --surface-hover: #1F1F2E;
  --text: #F0F0F5;
  --text-secondary: #8A8A9A;
  --border: #2A2A3A;
  --success: #52C41A;
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: light) {
  :root {
    --primary: #FF4D4F;
    --primary-dark: #D9363E;
    --secondary: #FF7A45;
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --surface-hover: #FFF5F5;
    --text: #1A1A2E;
    --text-secondary: #6B6B80;
    --border: #EBEBEB;
    --success: #52C41A;
  }
}

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

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 100px;
}

body.centered .container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 16px;
  padding-right: 16px;
}

body.centered .results {
  display: none;
}

.search-section {
  background: var(--bg);
  padding: 16px 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body:not(.centered) .search-section {
  position: sticky;
  top: 44px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
  width: 100%;
}

.search-box:focus-within {
  border-color: var(--primary);
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.clear-btn {
  padding: 8px 10px;
  margin-right: 4px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: none;
  line-height: 1;
  transition: color 0.2s;
}

.clear-btn:hover { color: var(--text); }
.clear-btn.visible { display: block; }

.search-btn {
  padding: 14px 24px;
  background: linear-gradient(135deg, #FF4D4F, #FF7A45);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.search-btn:hover { opacity: 0.9; }
.search-btn:active { transform: scale(0.98); }

.filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.filter-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  transition: background 0.2s;
  animation: fadeIn 0.3s ease forwards;
}

.result-item:hover { background: var(--surface-hover); }

.result-title {
  flex: 1;
  min-width: 160px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-date {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.action-btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}

.copy-btn { background: var(--primary); color: #fff; }
.copy-btn:hover { background: var(--primary-dark); }
.copy-btn.copied { background: var(--success); }
.open-btn { background: var(--surface-hover); color: var(--text); }
.open-btn:hover { background: var(--border); }

.loading, .empty, .error {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  color: var(--text);
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

@media (max-width: 600px) {
  .container { padding: 16px 12px 80px; }
  .search-section { padding: 12px 0; margin-bottom: 16px; }
  .search-btn { padding: 12px 18px; }
  .result-item { padding: 12px; }
  .result-title { min-width: 100%; }
  .filter-btn { padding: 8px 14px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .result-item { animation: none; }
  .spinner { animation: none; }
}

/* User Header */
.user-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  z-index: 150;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.user-header.hidden { display: none; }

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.user-info:hover { background: var(--surface-hover); }

.user-vip {
  color: #FFD700;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}

.user-vip.expired {
  color: var(--text-secondary);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF4D4F, #FF7A45);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-email {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 有 header 时 body 下移 */
body.has-header .container {
  padding-top: 68px;
}

body.has-header.centered .container {
  padding-top: 44px;
}

/* VIP Purchase Modal */
.vip-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.vip-modal.hidden { display: none; }

.vip-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 90%;
  text-align: center;
}

.vip-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.vip-modal-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.vip-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.vip-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.vip-option:hover {
  border-color: var(--primary);
}

.vip-option.selected {
  border-color: var(--primary);
  background: var(--surface-hover);
}

.vip-option-name {
  font-weight: 500;
}

.vip-option-price {
  color: var(--primary);
  font-weight: 600;
}

.vip-pay-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 12px;
}

.vip-pay-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.vip-close {
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
}

/* QR Code Modal */
.qr-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.qr-modal.hidden { display: none; }

.qr-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.qr-modal-title {
  font-size: 16px;
  margin-bottom: 16px;
}

.qr-modal-img {
  width: 200px;
  height: 200px;
  margin-bottom: 16px;
}

.qr-modal-tip {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Auth Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.modal h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.modal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form.hidden { display: none; }

.modal-input {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.modal-input:focus { border-color: var(--primary); }

.modal-input::placeholder { color: var(--text-secondary); }

.send-code-row {
  display: flex;
  gap: 8px;
}

.send-code-row .modal-input { flex: 1; }

.send-code-btn {
  padding: 12px 14px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-code-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-submit {
  padding: 13px;
  background: linear-gradient(135deg, #FF4D4F, #FF7A45);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}

.modal-submit:hover { opacity: 0.9; }
.modal-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.modal-error {
  font-size: 13px;
  color: var(--primary);
  min-height: 18px;
}