/* ===== Chat Bubbles ===== */
.chat-area {
  display: flex; flex-direction: column; gap: 14px;
  padding-bottom: 16px;
  overflow-y: auto;
  flex: 1; min-height: 0;
  scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(0,150,199,0.2); border-radius: 4px; }
.bubble {
  max-width: 88%; padding: 16px 20px;
  border-radius: var(--radius-md); font-size: 0.93rem; line-height: 1.65;
  animation: bubbleIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.bubble.bot {
  align-self: flex-start; background: var(--bg-card); color: var(--text-1);
  border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm);
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0077B6, #00B4D8);
  color: #fff; border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 150, 199, 0.25);
}
.bubble .bot-icon {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 700; color: var(--primary);
  margin-bottom: 8px; background: var(--primary-bg);
  padding: 2px 8px 2px 2px; border-radius: var(--radius-full); letter-spacing: 0.05em;
}
.bot-avatar {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  background: #fff; flex-shrink: 0;
}

.typing {
  display: flex; gap: 5px; padding: 16px 20px; align-self: flex-start;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm);
}
.typing-label { font-size: 0.78rem; font-weight: 600; color: var(--text-3); margin-right: 6px; white-space: nowrap; }
.typing-dot { width: 8px; height: 8px; background: var(--primary-light); border-radius: 50%; animation: typingDot 1.2s infinite; }
.typing-dot:nth-child(3) { animation-delay: 0.15s; }
.typing-dot:nth-child(4) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.25; transform: scale(0.7); }
  30% { opacity: 1; transform: scale(1.1); }
}

/* ===== Step Controls ===== */
.step-controls { animation: bubbleIn 0.35s cubic-bezier(0.34,1.56,0.64,1); margin-top: -4px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-option {
  padding: 11px 20px; border: 1px solid rgba(0, 150, 199, 0.2); border-radius: var(--radius-full);
  background: rgba(0, 150, 199, 0.06); color: var(--text-1); font-size: 0.86rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); font-family: var(--font);
  backdrop-filter: blur(8px);
}
.btn-option:hover { border-color: var(--primary); transform: translateY(-2px); background: rgba(0, 150, 199, 0.12); box-shadow: 0 4px 16px rgba(0, 150, 199, 0.15); }
.btn-option:active { transform: scale(0.97); }

.check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 7px; padding: 9px 16px;
  border: 1px solid rgba(0, 150, 199, 0.15); border-radius: var(--radius-full);
  background: rgba(0, 150, 199, 0.04); color: var(--text-1); cursor: pointer; font-size: 0.85rem; font-weight: 500;
  transition: var(--transition);
}
.check-item:hover { border-color: var(--primary); background: rgba(0, 150, 199, 0.08); }
.check-item.checked { border-color: var(--primary); background: rgba(0, 150, 199, 0.12); color: var(--primary); font-weight: 600; }
.check-item input { display: none; }

/* ===== Inputs ===== */
.wizard-input {
  width: 100%; padding: 13px 18px; border: 1px solid rgba(0, 150, 199, 0.18); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: var(--font); background: rgba(255, 255, 255, 0.8); color: var(--text-1);
  outline: none; transition: var(--transition);
}
.wizard-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 150, 199, 0.08); }
.wizard-input::placeholder { color: var(--text-4); }
textarea.wizard-input { min-height: 80px; resize: vertical; border-radius: var(--radius-md); }
.wizard-actions { display: flex; gap: 8px; margin-top: 10px; }
.wizard-back-btn { align-self: flex-start; font-size: 0.8rem; padding: 6px 14px; margin-top: -4px; opacity: 0.6; }
.wizard-back-btn:hover { opacity: 1; }

/* ===== Buttons ===== */
.btn {
  padding: 11px 22px; border-radius: var(--radius-full); font-size: 0.86rem; font-weight: 600;
  cursor: pointer; border: none; font-family: var(--font); transition: var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #0077B6, #00B4D8); color: #fff; box-shadow: 0 4px 16px rgba(0, 150, 199, 0.25); }
.btn-primary:hover { box-shadow: 0 6px 24px rgba(0, 150, 199, 0.35); transform: translateY(-1px); }
.btn-secondary { background: rgba(0, 150, 199, 0.08); color: var(--primary); border: 1px solid rgba(0, 150, 199, 0.2); }
.btn-secondary:hover { background: rgba(0, 150, 199, 0.15); transform: translateY(-1px); }
.btn-ghost { background: none; color: var(--text-3); }
.btn-ghost:hover { color: var(--text-1); background: rgba(0, 150, 199, 0.06); }
.btn-accent { background: linear-gradient(135deg, #FF6B35, #FFD166); color: #1A1A2E; font-weight: 700; box-shadow: 0 4px 16px rgba(255, 107, 53, 0.25); }
.btn-accent:hover { box-shadow: 0 6px 24px rgba(255, 107, 53, 0.35); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, var(--green), #00D2A0); color: #fff; box-shadow: 0 4px 16px rgba(0,184,148,0.25); }
.btn-success:hover { box-shadow: 0 6px 24px rgba(0,184,148,0.35); transform: translateY(-1px); }

/* ===== Review Card ===== */
.review-card {
  background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(0, 150, 199, 0.12); border-radius: var(--radius-md);
  padding: 24px; box-shadow: var(--shadow-md); overflow: hidden;
  backdrop-filter: blur(12px);
}
.review-card::before { content: ''; display: block; height: 3px; margin: -24px -24px 20px; background: linear-gradient(90deg, #0077B6, #00B4D8, #48CAE4, #ADE8F4); }
.review-card--final {
  border: 2px solid rgba(0, 150, 199, 0.2);
  box-shadow: 0 0 24px rgba(0, 150, 199, 0.06), var(--shadow-md);
  margin-top: 8px;
}
.review-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 0.86rem; }
.review-row:last-child { border-bottom: none; }
.review-label { color: var(--text-3); font-weight: 500; }
.review-value { color: var(--text-1); font-weight: 600; text-align: right; max-width: 60%; }

/* Divider between chat and review */
.chat-divider {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.72rem; font-weight: 700; color: var(--primary);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin: 16px 0 8px;
}
.chat-divider::before, .chat-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 150, 199, 0.25), transparent);
}

/* Generate panel (below chat area) */
.generate-panel {
  flex-shrink: 0;
  padding: 12px 0 8px;
  overflow-y: auto;
  max-height: 50vh;
}

/* Final action buttons */
.wizard-actions--final {
  display: flex; gap: 10px; margin-top: 16px; padding-bottom: 8px;
}

/* ===== Progress ===== */
.progress-timeline { margin-bottom: 20px; }
.timeline-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-left: 2px solid var(--border); margin-left: 15px; padding-left: 24px; position: relative; }
.timeline-row:last-child { border-left-color: transparent; }
.timeline-icon {
  position: absolute; left: -15px; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; border: 2px solid var(--border);
  background: var(--bg-page); color: var(--text-4); transition: var(--transition);
}
.timeline-icon.done { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 2px 8px rgba(0,184,148,0.25); }
.timeline-icon.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 12px rgba(0, 150, 199, 0.3); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 12px rgba(0, 150, 199, 0.3); } 50% { box-shadow: 0 0 24px rgba(0, 150, 199, 0.5); } }
.timeline-label { font-size: 0.9rem; color: var(--text-2); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.current-action { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius-sm); padding: 14px 20px; font-size: 0.88rem; color: var(--text-1); font-weight: 500; margin-top: 16px; }

.log-box { background: rgba(245, 248, 252, 0.95); color: #0077B6; font-family: var(--font-mono); font-size: 0.74rem; padding: 18px; border-radius: var(--radius-md); max-height: 220px; overflow-y: auto; line-height: 1.7; white-space: pre-wrap; margin-top: 8px; border: 1px solid rgba(0, 150, 199, 0.1); }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; }
.file-tag { display: inline-flex; align-items: center; padding: 5px 12px; background: rgba(0, 150, 199, 0.08); color: var(--primary); border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; border: 1px solid rgba(0, 150, 199, 0.15); }

/* ===== Deploy / Settings / Result ===== */
.deploy-panel { background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(0, 150, 199, 0.1); border-radius: var(--radius-md); padding: 28px; box-shadow: var(--shadow-sm); backdrop-filter: blur(12px); }
.deploy-panel h3 { font-size: 1rem; font-weight: 700; color: var(--text-1); margin-bottom: 20px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.settings-section { background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(0, 150, 199, 0.1); border-radius: var(--radius-md); padding: 28px; margin-bottom: 16px; box-shadow: var(--shadow-sm); backdrop-filter: blur(12px); }
.settings-section h3 { font-size: 0.95rem; font-weight: 700; color: var(--text-1); margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border-light); }
.result-url { display: inline-flex; align-items: center; gap: 8px; padding: 14px 24px; background: linear-gradient(135deg, var(--green), #00D2A0); color: #fff; border-radius: var(--radius-full); font-weight: 700; text-decoration: none; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0,184,148,0.25); transition: var(--transition); }
.result-url:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,184,148,0.35); }

/* ===== Design System Editor ===== */
.ds-editor { max-width: 960px; margin: 0 auto; }
.ds-editor-header {
  display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px;
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-page); padding: 0 0 16px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.ds-editor-title { font-size: 1.6rem; font-weight: 700; color: var(--text-1); margin-bottom: 6px; }
.ds-editor-desc { color: var(--text-3); font-size: 0.88rem; }
.ds-editor-actions { display: flex; gap: 8px; }

.ds-sections { display: flex; flex-direction: column; gap: 48px; }
.ds-section { }
.ds-section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid var(--text-1); }
.ds-section-num { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; color: var(--primary); }
.ds-section-title { font-size: 1.05rem; font-weight: 700; color: var(--text-1); }

.ds-group-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); margin: 20px 0 10px; }
.ds-group-label:first-child { margin-top: 0; }

/* Color Pickers */
.ds-color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ds-color-chip { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.8); border: 1px solid rgba(0, 150, 199, 0.1); border-radius: 8px; padding: 6px 14px 6px 6px; cursor: pointer; transition: var(--transition); }
.ds-color-chip:hover { box-shadow: 0 2px 8px rgba(0, 150, 199, 0.1); }
.ds-color-chip input[type="color"] { width: 36px; height: 36px; border: none; border-radius: 6px; cursor: pointer; padding: 0; background: none; }
.ds-color-chip input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ds-color-chip input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,0.08); border-radius: 6px; }
.ds-color-label { font-size: 0.8rem; font-weight: 600; color: var(--text-1); line-height: 1.2; }
.ds-color-hex { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-3); }

/* Select */
.ds-select { width: 100%; max-width: 380px; padding: 10px 14px; border: 1px solid rgba(0, 150, 199, 0.15); border-radius: 8px; background: rgba(255, 255, 255, 0.8); color: var(--text-1); font-size: 0.88rem; font-family: var(--font); outline: none; transition: var(--transition); }
.ds-select:focus { border-color: var(--primary); }

/* Sliders */
.ds-slider-wrap { display: flex; align-items: center; gap: 12px; max-width: 380px; }
.ds-slider-inline { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.ds-range { width: 120px; accent-color: var(--primary); cursor: pointer; }
.ds-range-val { font-family: var(--font-mono); font-size: 0.76rem; font-weight: 600; color: var(--text-2); min-width: 56px; text-align: right; }

/* Type Preview */
.ds-type-preview { background: rgba(255, 255, 255, 0.8); border: 1px solid rgba(0, 150, 199, 0.1); border-radius: 10px; overflow: hidden; }
.ds-type-row { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border-light); gap: 16px; }
.ds-type-row:last-child { border-bottom: none; }
.ds-type-token { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; color: var(--primary); min-width: 60px; }
.ds-type-sample { flex: 1; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Spacing */
.ds-spacing-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.ds-spacing-label { font-size: 0.84rem; font-weight: 500; color: var(--text-2); min-width: 160px; }
.ds-spacing-bar { height: 8px; background: var(--primary); border-radius: 4px; opacity: 0.5; transition: width 0.2s; min-width: 4px; }

/* Radius Preview */
.ds-radius-preview { display: flex; flex-wrap: wrap; gap: 24px; }
.ds-radius-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ds-radius-box { width: 56px; height: 56px; background: rgba(0, 150, 199, 0.08); border: 1.5px solid rgba(0, 150, 199, 0.2); }
.ds-radius-label { font-size: 0.75rem; color: var(--text-3); }

/* Shadow Select */
.ds-shadow-select { display: flex; flex-wrap: wrap; gap: 16px; }
.ds-shadow-item { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; padding: 12px; border: 2px solid transparent; border-radius: 10px; transition: var(--transition); }
.ds-shadow-item:hover { background: rgba(0, 150, 199, 0.04); }
.ds-shadow-item.active { border-color: var(--primary); background: rgba(0, 150, 199, 0.06); }
.ds-shadow-box { width: 80px; height: 52px; background: rgba(255, 255, 255, 0.9); border-radius: 8px; border: 1px solid rgba(0, 150, 199, 0.1); }
.ds-shadow-label { font-size: 0.76rem; font-weight: 600; color: var(--text-2); }

/* Animation Demo */
.ds-anim-demo { width: 36px; height: 36px; background: var(--primary); border-radius: 6px; cursor: pointer; flex-shrink: 0; }

/* Live Preview */
.ds-preview-frame { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.ds-prev { min-height: 200px; }

/* Toast */
.ds-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: linear-gradient(135deg, #0077B6, #00B4D8); color: #fff; padding: 12px 28px; border-radius: var(--radius-full); font-size: 0.86rem; font-weight: 600; opacity: 0; transition: all 0.3s; z-index: 9999; pointer-events: none; }
.ds-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Scrape Card ===== */
.scrape-card {
  background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(0, 150, 199, 0.1); border-radius: var(--radius-md);
  padding: 20px; box-shadow: var(--shadow-sm); overflow: hidden;
  animation: bubbleIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
  backdrop-filter: blur(12px);
}
.scrape-card::before { content: ''; display: block; height: 3px; margin: -20px -20px 16px; background: linear-gradient(90deg, #0077B6, #00B4D8, var(--green)); }
.scrape-header { font-size: 0.82rem; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.scrape-row { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border-light); font-size: 0.82rem; align-items: baseline; }
.scrape-row:last-child { border-bottom: none; }
.scrape-label { color: var(--text-3); font-weight: 600; min-width: 70px; flex-shrink: 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.scrape-value { color: var(--text-1); flex: 1; line-height: 1.5; }
.scrape-tag { display: inline-block; background: var(--primary-bg); color: var(--primary); padding: 1px 8px; border-radius: var(--radius-full); font-size: 0.74rem; font-weight: 600; margin: 1px 2px; }
.scrape-heading { font-size: 0.8rem; color: var(--text-2); line-height: 1.5; }
.scrape-h-level { font-family: var(--font-mono); font-size: 0.68rem; color: var(--primary); font-weight: 600; }
.scrape-swatch { display: inline-block; width: 20px; height: 20px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); vertical-align: middle; margin: 1px 2px; }
.scrape-excerpt { font-size: 0.78rem; color: var(--text-3); line-height: 1.6; }

/* ===== Chat Input ===== */
.chat-input-wrap {
  flex-shrink: 0;
  padding: 12px 0 4px;
}
.chat-input-container {
  display: flex; align-items: flex-end; gap: 10px;
  background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(0, 150, 199, 0.15);
  border-radius: var(--radius-md); padding: 8px 8px 8px 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.chat-input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 150, 199, 0.08), 0 0 20px rgba(0, 150, 199, 0.05);
}
.chat-input {
  flex: 1; border: none; outline: none; resize: none;
  font-size: 0.9rem; font-family: var(--font); color: var(--text-1);
  background: transparent; line-height: 1.5;
  max-height: 120px; padding: 6px 0;
}
.chat-input::placeholder { color: var(--text-4); }
.chat-input:disabled { opacity: 0.5; }
.chat-send-btn {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, #0077B6, #00B4D8);
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: var(--transition);
}
.chat-send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0, 150, 199, 0.25); }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat-btn-group {
  display: flex; flex-wrap: wrap; gap: 8px;
  animation: bubbleIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

/* ===== Chat History Panel ===== */
.chat-history-panel {
  flex: 1; display: flex; flex-direction: column;
  padding: 20px 0; min-height: 0;
}
.chat-history-title {
  font-size: 0.85rem; font-weight: 700; color: var(--text-3);
  margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.08em;
}
.chat-history-list {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  min-height: 0;
}
.chat-history-item {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 150, 199, 0.04); border: 1px solid rgba(0, 150, 199, 0.08);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; transition: 0.2s;
}
.chat-history-item:hover {
  background: rgba(0, 150, 199, 0.08); border-color: rgba(0, 150, 199, 0.2);
}
.chat-history-item-info { flex: 1; min-width: 0; }
.chat-history-item-label {
  font-size: 0.88rem; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-history-item-date { font-size: 0.72rem; color: var(--text-3); margin-top: 2px; }
.chat-history-delete {
  flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(239, 68, 68, 0.08); color: rgba(239, 68, 68, 0.5);
  font-size: 1.1rem; cursor: pointer; transition: 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.chat-history-delete:hover { background: rgba(239, 68, 68, 0.15); color: #EF4444; }

@media (max-width: 768px) {
  .ds-editor-header { flex-direction: column; }
  .ds-color-row { gap: 8px; }
  .ds-color-chip { flex: 1; min-width: 140px; }
  .ds-type-row { flex-wrap: wrap; }
  .ds-spacing-label { min-width: 120px; font-size: 0.78rem; }
  .ds-radius-preview { gap: 16px; }
}

/* ===== Template Gallery ===== */
.template-filter {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px;
}
.template-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.template-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
}
.template-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.template-thumb {
  width: 100%; aspect-ratio: 16/10; overflow: hidden; background: var(--bg-dark);
}
.template-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.template-info { padding: 16px; flex: 1; }
.template-category-tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  color: var(--primary); background: var(--primary-bg);
  padding: 2px 10px; border-radius: var(--radius-full); margin-bottom: 8px;
}
.template-name {
  font-size: 0.95rem; font-weight: 700; color: var(--text-heading); margin-bottom: 6px;
}
.template-desc {
  font-size: 0.82rem; color: var(--text-sub); line-height: 1.5;
}
.template-use-btn {
  margin: 0 16px 16px; font-size: 0.82rem; padding: 10px;
}
@media (max-width: 600px) {
  .template-grid { grid-template-columns: 1fr; }
}

/* ===== Image Upload ===== */
.upload-section { margin: 16px 0; }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: 0.82rem;
  color: var(--text-sub);
  display: flex; flex-direction: column; align-items: center;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.upload-preview {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px;
}
.upload-thumb {
  position: relative; width: 80px;
}
.upload-thumb img {
  width: 80px; height: 60px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  display: block;
}
.upload-thumb-name {
  font-size: 0.68rem; color: var(--text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.upload-thumb-remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--error); color: #fff;
  border: none; cursor: pointer;
  font-size: 0.75rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Admin Dashboard ===== */
.admin-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; text-align: center;
}
.stat-number {
  font-size: 1.1rem; font-weight: 800; color: var(--primary);
  margin-bottom: 2px; line-height: 1.2;
}
.stat-label {
  font-size: 0.72rem; color: var(--text-sub); font-weight: 500;
}
.admin-section { margin-bottom: 24px; }
.admin-section-title {
  font-size: 0.9rem; font-weight: 600; color: var(--text-heading);
  margin-bottom: 12px;
}
.admin-notice {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px;
  font-size: 0.88rem; color: var(--text-2);
}
.admin-chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 120px; padding: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.chart-bar-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end;
}
.chart-bar {
  width: 100%; max-width: 40px;
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}
.chart-count {
  font-size: 0.7rem; color: var(--text-2); margin-top: 4px; font-weight: 600;
}
.chart-label {
  font-size: 0.68rem; color: var(--text-sub); margin-top: 2px;
}
.admin-log-table {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
  max-height: 300px; overflow-y: auto;
}
.log-header, .log-row {
  display: grid; grid-template-columns: 1fr 1.5fr 0.8fr 0.8fr;
  padding: 10px 14px; font-size: 0.82rem;
}
.log-header {
  background: rgba(0, 150, 199, 0.06); color: var(--text-heading);
  font-weight: 600; position: sticky; top: 0;
}
.log-row {
  border-top: 1px solid var(--border-subtle); color: var(--text-2);
}
/* Admin 5-col stats */
.admin-stats--5col { grid-template-columns: repeat(5, 1fr); }

/* Admin 6-col log table */
.admin-log-6col { grid-template-columns: 1.2fr 0.8fr 1fr 0.8fr 0.8fr 0.6fr; }

/* Mobile card list - hidden on desktop */
.admin-log-mobile { display: none; }
.admin-log-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
  transition: var(--transition);
}
.admin-log-card:hover { border-color: rgba(0, 150, 199, 0.3); background: rgba(0, 150, 199, 0.02); }

@media (max-width: 768px) {
  .admin-stats--5col { grid-template-columns: repeat(3, 1fr); }
  .admin-log-desktop { display: none; }
  .admin-log-mobile { display: flex; }
}
@media (max-width: 600px) {
  .admin-stats, .admin-stats--5col { grid-template-columns: repeat(2, 1fr); }
  .stat-number { font-size: 1.2rem; }
}

/* ===== Project History ===== */
.project-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.project-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 18px;
  cursor: pointer; transition: transform var(--transition), box-shadow var(--transition);
}
.project-card:hover {
  transform: translateY(-1px); box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.project-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.project-card-name {
  font-size: 0.92rem; font-weight: 700; color: var(--text-heading);
}
.project-card-type {
  font-size: 0.72rem; font-weight: 600; color: var(--primary);
  background: var(--primary-bg); padding: 2px 10px; border-radius: var(--radius-full);
}
.project-card-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--text-sub);
}

/* ===== Project Detail Overlay ===== */
.project-detail-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.project-detail-panel {
  background: var(--bg-page); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 1200px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.detail-header h3 {
  font-size: 1.1rem; font-weight: 700; color: var(--text-heading);
}
.detail-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: none;
  color: var(--text-2); font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.detail-close:hover { background: rgba(0, 150, 199, 0.08); color: var(--text-1); }
.detail-info { padding: 16px 24px; }
.detail-row {
  display: flex; padding: 6px 0; font-size: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}
.detail-label {
  width: 100px; flex-shrink: 0; color: var(--text-sub); font-weight: 500;
}
.detail-row span:last-child { color: var(--text-2); }
.detail-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.detail-tab {
  padding: 10px 20px; border: none; background: none;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  font-family: var(--font); color: var(--text-sub);
  border-bottom: 2px solid transparent;
}
.detail-tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
}
.detail-content { padding: 0; }
.detail-preview-actions {
  padding: 10px 16px; display: flex; justify-content: flex-end;
  border-bottom: 1px solid var(--border-subtle);
}
.detail-newtab-btn { font-size: 0.78rem; padding: 6px 14px; }
.detail-actions-bar {
  display: flex; gap: 8px; padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.detail-actions-bar .btn { font-size: 0.78rem; padding: 8px 16px; }
.detail-iframe {
  width: 100%; height: 70vh; border: none; display: block;
}

/* Annotations */
.detail-annotations {
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: rgba(239, 68, 68, 0.03);
}
.annotations-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.annotations-hint {
  font-size: 0.72rem; color: var(--text-sub);
}
.annotations-list {
  max-height: 200px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.annotation-entry {
  background: rgba(255, 255, 255, 0.8); border: 1px solid rgba(239, 68, 68, 0.12);
  border-radius: 8px; padding: 8px 10px;
}
.annotation-target {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.annotation-tag {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
  color: #EF4444; background: rgba(239, 68, 68, 0.08);
  padding: 1px 6px; border-radius: 4px;
}
.annotation-preview {
  font-size: 0.78rem; color: var(--text-sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.annotation-remove {
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: rgba(239, 68, 68, 0.08); color: #EF4444;
  cursor: pointer; font-size: 0.9rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.annotation-input {
  font-size: 0.82rem !important; padding: 8px 10px !important;
}
.detail-prompt-text {
  margin: 0; padding: 16px 24px; background: var(--bg-dark);
  color: var(--text-2); font-family: var(--font-mono); font-size: 0.78rem;
  white-space: pre-wrap; line-height: 1.6; max-height: 400px; overflow-y: auto;
}

/* Edit bar (sticky at top of iframe) */
.edit-bar-sticky {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 24px;
  background: rgba(255, 107, 53, 0.08);
  border-bottom: 2px solid rgba(255, 107, 53, 0.25);
  position: sticky; top: 0; z-index: 5;
}
.edit-bar-label {
  font-size: 0.8rem; font-weight: 600; color: var(--accent);
}

/* ===== Order CTA ===== */
.order-cta {
  margin-top: 24px;
}
.order-cta-inner {
  background: linear-gradient(135deg, rgba(0, 150, 199, 0.08), rgba(0, 119, 182, 0.08));
  border: 1px solid rgba(0, 150, 199, 0.15);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
}
.order-cta-text h3 {
  font-size: 1rem; font-weight: 700; color: var(--text-heading); margin-bottom: 4px;
}
.order-cta-text p {
  font-size: 0.85rem; color: var(--text-sub);
}
.order-cta-btn {
  white-space: nowrap; padding: 12px 28px; font-size: 0.95rem;
}
@media (max-width: 600px) {
  .order-cta-inner { flex-direction: column; text-align: center; padding: 20px 16px; }
  .order-cta-btn { width: 100%; }
}

/* ===== Order Plans ===== */
.order-plans { display: flex; flex-direction: column; gap: 8px; }
.order-plan { cursor: pointer; display: block; }
.order-plan input { display: none; }
.order-plan-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; transition: var(--transition);
}
.order-plan input:checked + .order-plan-card {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: 0 0 0 1px var(--primary);
}
.order-plan-card:hover { border-color: rgba(0, 150, 199, 0.3); }
.order-plan-name { font-size: 0.9rem; font-weight: 700; color: var(--text-heading); }
.order-plan-price { font-size: 1.1rem; font-weight: 800; color: var(--primary); margin: 2px 0; }
.order-plan-desc { font-size: 0.78rem; color: var(--text-sub); }

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  /* Chat */
  .bubble { max-width: 92%; padding: 12px 16px; font-size: 0.88rem; }
  .bot-icon { font-size: 0.72rem; }
  .chat-input-wrap { padding: 8px; }
  .chat-input-container { gap: 8px; }
  .chat-input { font-size: 0.88rem; padding: 10px 14px; }
  .chat-send-btn { width: 38px; height: 38px; }
  .chat-btn-group { gap: 6px; }
  .btn-option { padding: 8px 14px; font-size: 0.8rem; }

  /* Review card */
  .review-card { padding: 14px; }
  .review-row { font-size: 0.82rem; flex-direction: column; gap: 2px; }
  .review-label { min-width: unset; }

  /* Progress */
  .progress-timeline { gap: 8px; }
  .log-box { font-size: 0.7rem; max-height: 150px; }
  .file-tag { font-size: 0.7rem; padding: 3px 8px; }

  /* Template grid */
  .template-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
  .template-filter { gap: 6px; }
  .template-info { padding: 12px; }
  .template-use-btn { margin: 0 12px 12px; }

  /* Admin */
  .admin-chart { height: 100px; padding: 8px; }
  .chart-count { font-size: 0.65rem; }
  .chart-label { font-size: 0.62rem; }

  /* Project detail overlay */
  .project-detail-overlay { padding: 0; align-items: flex-end; }
  .project-detail-panel {
    max-width: 100% !important; max-height: 95vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .detail-header { padding: 16px; position: sticky; top: 0; background: var(--bg-page); z-index: 2; }
  .detail-header h3 { font-size: 1rem; }
  .detail-info { padding: 12px 16px; }
  .detail-row { font-size: 0.82rem; flex-wrap: wrap; }
  .detail-label { width: 80px; font-size: 0.78rem; }
  .detail-actions-bar { padding: 10px 16px; gap: 6px; }
  .detail-actions-bar .btn { padding: 7px 12px; font-size: 0.72rem; }
  .detail-iframe { height: 400px; }
  .detail-tabs { padding: 0 16px; overflow-x: auto; }
  .detail-tab { padding: 8px 14px; font-size: 0.8rem; white-space: nowrap; }
  .detail-prompt-text { padding: 12px 16px; font-size: 0.72rem; max-height: 250px; }
  /* Order plans responsive */
  .order-plans { gap: 6px; }
  .order-plan-card { padding: 12px; }
  .order-plan-name { font-size: 0.82rem; }
  .order-plan-price { font-size: 0.95rem; }
  .order-plan-desc { font-size: 0.75rem; }

  /* Project cards */
  .project-card { padding: 12px 14px; }
  .project-card-name { font-size: 0.88rem; }
  .project-card-meta { gap: 10px; font-size: 0.72rem; }

  /* Design system editor */
  .ds-section { padding: 14px; }
}

@media (max-width: 480px) {
  .bubble { max-width: 95%; padding: 10px 14px; font-size: 0.85rem; }
  .template-grid { grid-template-columns: 1fr; }
  .admin-stats, .admin-stats--5col { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-number { font-size: 1.2rem; }
  .project-detail-panel { max-height: 100vh; max-width: 100% !important; border-radius: 0; }
  .detail-iframe { height: 280px; }
  .detail-row { flex-direction: column; gap: 2px; }
  .detail-label { width: auto; }
}

/* ===== Generation Progress Enhancements ===== */

/* Animated dots after "生成中" */
.generating-dots span {
  font-size: 1.2rem; font-weight: 700; color: var(--primary);
  animation: dotBlink 1.4s infinite;
}
.generating-dots span:nth-child(2) { animation-delay: 0.2s; }
.generating-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBlink {
  0%, 20% { opacity: 0.2; }
  40% { opacity: 1; }
  60%, 100% { opacity: 0.2; }
}

/* Fun rotating tip bar */
/* Mascot animations for generation */
.generating-mascot {
  width: 80px; height: 80px; object-fit: contain;
  animation: mascotWork 2s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(0, 150, 199, 0.15));
}
@keyframes mascotWork {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-6px) rotate(-3deg); }
  75% { transform: translateY(-4px) rotate(3deg); }
}
.celebration-mascot {
  width: 96px; height: 96px; object-fit: contain;
  animation: mascotCelebrate 0.6s ease-in-out 3;
  filter: drop-shadow(0 6px 20px rgba(0, 150, 199, 0.25));
}
@keyframes mascotCelebrate {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-8deg); }
  75% { transform: scale(1.1) rotate(8deg); }
}

.generation-tip {
  background: linear-gradient(135deg, rgba(0, 150, 199, 0.06), rgba(72, 202, 228, 0.06));
  border: 1px solid rgba(0, 150, 199, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 20px;
  transition: opacity 0.25s, transform 0.25s;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* File counter badge */
.file-section-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.file-counter {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px;
  background: var(--primary); color: #fff;
  border-radius: var(--radius-full);
  font-size: 0.72rem; font-weight: 700;
  font-family: var(--font-mono);
}
@keyframes counterBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.counter-bump { animation: counterBump 0.35s ease; }

/* File tag pop-in */
.file-tag-pop {
  animation: fileTagPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fileTagPop {
  from { opacity: 0; transform: scale(0.7) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Celebration canvas */
.celebration-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 400px;
  pointer-events: none; z-index: 10;
}

/* Result reveal animation */
.result-reveal {
  animation: resultReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes resultReveal {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Order CTA Enhancement ===== */
.order-cta-inner {
  position: relative;
  overflow: hidden;
}
.order-cta-inner::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255, 107, 53, 0.04) 0%, transparent 50%);
  animation: ctaPulse 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ctaPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ===== Bot greeting bubble enhancement ===== */
.bubble.bot.greeting {
  border-image: linear-gradient(135deg, var(--primary), var(--primary-light)) 1;
  border-image-slice: 1;
  border-left: 3px solid;
  border-left-color: var(--primary);
}
