/* ============ CSS Variables ============ */
:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #5A4BD1;
  --secondary: #00CEC9;
  --accent: #FD79A8;
  --bg: #F8F9FE;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-light: #636E72;
  --border: #E8E8F0;
  --shadow: 0 4px 24px rgba(108, 92, 231, 0.08);
  --shadow-hover: 0 8px 40px rgba(108, 92, 231, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ Reset & Base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; font-family: inherit; }
input { font-family: inherit; }

/* ============ Layout ============ */
.container { max-width: 1300px; margin: 0 auto; padding: 0 24px; }

/* ============ Navbar ============ */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  background: rgba(255,255,255,0.9);
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar .logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar .logo span { font-size: 24px; }
.navbar .nav-links { display: flex; align-items: center; gap: 16px; }
.navbar .nav-links a {
  color: var(--text-light);
  font-weight: 500;
  transition: var(--transition);
  font-size: 15px;
}
.navbar .nav-links a:hover { color: var(--primary); }
.credits-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(108, 92, 231, 0.4);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

/* ============ Hero ============ */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}
.hero h1 {
  font-size: 42px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.hero p {
  font-size: 17px;
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto;
}

/* ============ Workspace (Left-Right Layout) ============ */
.workspace {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 48px;
}
.workspace-left {
  flex: 0 0 340px;
  min-width: 0;
}
.workspace-right {
  flex: 1;
  min-width: 0;
}
.workspace-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ============ Template List (Vertical Compact) ============ */
.template-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: 8px;
}
.template-list::-webkit-scrollbar { width: 4px; }
.template-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.template-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 22px 20px;
  border: 2px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}
.template-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), var(--secondary));
  transform: scaleY(0);
  transition: var(--transition);
}
.template-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.template-card:hover::before { transform: scaleY(1); }
.template-card.selected {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  background: rgba(108,92,231,0.03);
}
.template-card.selected::before { transform: scaleY(1); }
.template-card .icon {
  font-size: 32px;
  flex-shrink: 0;
}
.template-card .card-body {
  flex: 1;
  min-width: 0;
}
.template-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-card p {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.template-card .category {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-light);
}
.template-card .cost {
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

/* ============ Generator Panel ============ */
.generator {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.generator h2 {
  font-size: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 36px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 20px;
  position: relative;
}
.upload-area:hover { border-color: var(--primary-light); background: rgba(108,92,231,0.02); }
.upload-area .icon { font-size: 40px; margin-bottom: 8px; }
.upload-area p { color: var(--text-light); font-size: 14px; }
.upload-area input { display: none; }
.upload-preview {
  max-width: 260px;
  max-height: 260px;
  border-radius: var(--radius-sm);
  margin: 10px auto 0;
}
.prompt-input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  transition: var(--transition);
  margin-bottom: 20px;
}
.prompt-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108,92,231,0.1);
}
.generate-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.generate-btn {
  padding: 12px 36px;
  font-size: 15px;
}

/* ============ Result ============ */
.result-panel {
  display: none;
  text-align: center;
  padding: 28px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.result-panel.show { display: block; }
.result-panel h3 { margin-bottom: 16px; font-size: 18px; }
.result-panel img {
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--radius-sm);
  margin: 0 auto 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}
.result-panel .download-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-weight: 600;
}

/* ============ Modal ============ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal h2 {
  font-size: 22px;
  margin-bottom: 8px;
  text-align: center;
}
.modal .subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}
.modal .form-group { margin-bottom: 16px; }
.modal label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-light);
}
.modal input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: var(--transition);
}
.modal input:focus { outline: none; border-color: var(--primary); }
.code-row { display: flex; gap: 12px; }
.code-row input { flex: 1; }
.code-row button {
  white-space: nowrap;
  padding: 12px 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  transition: var(--transition);
}
.code-row button:hover { background: var(--primary); color: #fff; }
.code-row button:disabled { opacity: 0.5; cursor: not-allowed; }
.modal .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ============ Recharge Page (overlay) ============ */
.recharge-page {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}
.recharge-page .container { padding-top: 60px; }
.recharge-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}
.recharge-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  font-size: 22px;
  color: var(--text-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.recharge-close:hover { background: var(--bg); color: var(--text); }
.recharge-section h2 { font-size: 24px; margin-bottom: 8px; }
.recharge-section .subtitle { color: var(--text-light); margin-bottom: 24px; }
.recharge-packages {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.recharge-pkg {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 28px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  min-width: 120px;
}
.recharge-pkg:hover { border-color: var(--primary); transform: translateY(-2px); }
.recharge-pkg.selected { border-color: var(--primary); background: rgba(108,92,231,0.05); }
.recharge-pkg .price { font-size: 26px; font-weight: 800; color: var(--primary); }
.recharge-pkg .credits { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.qr-wrapper { display: none; margin-top: 20px; }
.qr-wrapper.show { display: block; }
.qr-wrapper img {
  width: 180px; height: 180px;
  margin: 0 auto 12px;
  border-radius: var(--radius-sm);
}
.qr-wrapper p { color: var(--text-light); font-size: 14px; }

/* ============ Footer ============ */
.footer {
  text-align: center;
  padding: 32px 0;
  color: var(--text-light);
  font-size: 14px;
  border-top: 1px solid var(--border);
}

/* ============ Loading ============ */
.loading-spinner {
  display: none;
  text-align: center;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.loading-spinner.show { display: block; }
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 24px; right: 24px;
  background: var(--card);
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 2000;
  transform: translateX(120%);
  transition: var(--transition);
  font-weight: 500;
  max-width: 360px;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--secondary); }
.toast.error { border-left: 4px solid #e74c3c; }

/* ============ Language Switch (Capsule) ============ */
.lang-switch {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 3px;
  cursor: pointer;
  user-select: none;
  min-width: 72px;
  height: 32px;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.lang-switch:hover { border-color: var(--primary-light); }
.lang-option {
  position: relative;
  z-index: 2;
  width: 50%;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  transition: color 0.25s;
  line-height: 26px;
}
.lang-option.active { color: #fff; }
.lang-slider {
  position: absolute;
  top: 3px; left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--primary);
  border-radius: 17px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}
.lang-slider.zh { transform: translateX(100%); }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
  }
  .workspace-left {
    flex: none;
    width: 100%;
  }
  .template-list {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    overflow-y: visible;
  }
  .template-card {
    flex: 0 0 calc(50% - 5px);
  }
  .hero h1 { font-size: 32px; }
  .hero { padding: 32px 0 20px; }
}
@media (max-width: 480px) {
  .template-card {
    flex: 0 0 100%;
  }
  .navbar .nav-links { gap: 10px; }
  .generator { padding: 20px; }
}
/* 新增样式 - 追加到 style.css 末尾 */

/* === 弹窗关闭按钮 === */
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  font-size: 20px;
  color: var(--text-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  border: none;
  cursor: pointer;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* === Modal 内部双按钮布局 === */
.modal-btns {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.modal-btns .btn {
  flex: 1;
  justify-content: center;
}

/* === 验证码发送按钮倒计时样式 === */
.code-row button.counting {
  background: var(--border);
  color: var(--text-light);
  cursor: not-allowed;
}

/* === 密码输入框 === */
.modal input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: var(--transition);
}
.modal input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* Forgot password link */
.forgot-link {
  display: block;
  text-align: right;
  font-size: 13px;
  color: var(--primary, #6c5ce7);
  text-decoration: none;
  margin-bottom: 12px;
  cursor: pointer;
}
.forgot-link:hover {
  text-decoration: underline;
}

/* Feedback floating button */

/* ============ Feedback Widget ============ */
#feedbackBtn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(108,92,231,0.45);
  z-index: 9998;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}
#feedbackBtn:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 10px 32px rgba(108,92,231,0.55);
}
#feedbackBtn:active {
  transform: translateY(-1px) scale(1.02);
}

/* Feedback panel - slide up from button */
#feedbackPanel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.18), 0 2px 8px rgba(108,92,231,0.1);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: feedbackSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
#feedbackPanel.show {
  display: flex;
}
@keyframes feedbackSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel header */
.fb-header {
  background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
  color: #fff;
  padding: 20px 24px 16px;
  position: relative;
}
.fb-header h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: 0.3px;
}
.fb-header p {
  font-size: 13px;
  opacity: 0.85;
  margin: 0;
}
.fb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}
.fb-close:hover {
  background: rgba(255,255,255,0.35);
}

/* Panel body */
.fb-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.fb-body .fb-field {
  margin-bottom: 16px;
}
.fb-body .fb-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #636E72;
  margin-bottom: 6px;
}
.fb-body .fb-field input,
.fb-body .fb-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #E8E8F0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #F8F9FE;
  resize: none;
}
.fb-body .fb-field input:focus,
.fb-body .fb-field textarea:focus {
  outline: none;
  border-color: #6C5CE7;
  box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
  background: #fff;
}
.fb-body .fb-field textarea {
  min-height: 90px;
  line-height: 1.5;
}

/* Panel footer */
.fb-footer {
  padding: 12px 24px 20px;
  display: flex;
  gap: 10px;
}
.fb-footer .fb-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.fb-btn-send {
  background: linear-gradient(135deg, #6C5CE7, #5A4BD1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(108,92,231,0.3);
}
.fb-btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108,92,231,0.4);
}
.fb-btn-history {
  background: #F8F9FE;
  color: #6C5CE7;
  border: 2px solid #E8E8F0;
}
.fb-btn-history:hover {
  background: #EDE9FE;
  border-color: #6C5CE7;
}

/* History list inside panel */
.fb-history {
  margin-top: 8px;
  border-top: 1px solid #E8E8F0;
  padding-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}
.fb-history-item {
  padding: 10px 12px;
  background: #F8F9FE;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.fb-history-item .fb-hi-subject {
  font-weight: 600;
  color: #2D3436;
  margin-bottom: 2px;
}
.fb-history-item .fb-hi-content {
  color: #636E72;
  margin-bottom: 4px;
  line-height: 1.4;
}
.fb-history-item .fb-hi-reply {
  background: #EDE9FE;
  padding: 6px 10px;
  border-radius: 8px;
  color: #5A4BD1;
  font-size: 12px;
  margin-top: 6px;
}
.fb-history-item .fb-hi-reply::before {
  content: 💬 回复：;
  font-weight: 600;
}
.fb-history-item .fb-hi-meta {
  font-size: 11px;
  color: #b2bec3;
  margin-top: 4px;
}
.fb-history-empty {
  text-align: center;
  color: #b2bec3;
  padding: 16px 0;
  font-size: 13px;
}

/* Mobile responsive */
@media (max-width: 480px) {
  #feedbackPanel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 90px;
    max-height: 70vh;
  }
  #feedbackBtn {
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
}

/* Unread badge on feedback button */
.fb-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: #FF3B30;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(255,59,48,0.4);
  animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}
@keyframes badgePop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
/* feedbackBtn position context already set by position:fixed above */

/* Credits badge next to icon */
.template-card .icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 52px;
  justify-content: center;
}
.template-card .icon-wrap .icon {
  font-size: 32px;
  line-height: 1;
}
.template-card .credits-badge {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
