:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --error: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(79, 70, 229, 0.05) 0%, transparent 20%),
    radial-gradient(circle at 90% 80%, rgba(124, 58, 237, 0.05) 0%, transparent 20%),
    radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.03) 0%, transparent 30%);
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  padding: 2.5rem 0 1.5rem;
  text-align: center;
  position: relative;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 2px;
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 2rem;
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-badge {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

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

.main-content {
  flex: 1;
  padding-bottom: 2rem;
  animation: fadeIn 0.6s ease;
}

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

.editor-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(79, 70, 229, 0.1);
  transition: all 0.3s ease;
}

.editor-section:hover {
  box-shadow: 0 8px 32px rgba(79, 70, 229, 0.12);
  border-color: rgba(79, 70, 229, 0.2);
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.toolbar-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.editor-textarea {
  width: 100%;
  min-height: 340px;
  padding: 1.25rem;
  border: none;
  outline: none;
  resize: vertical;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: transparent;
}

.editor-textarea::placeholder {
  color: #b0b8c4;
}

.editor-actions {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  align-items: center;
}

.style-mode-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}

.style-mode-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.style-mode-btns {
  display: flex;
  gap: 0.25rem;
  background: #f3f4f6;
  padding: 0.25rem;
  border-radius: 8px;
}

.style-mode-btn {
  padding: 0.4rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.style-mode-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.5);
}

.style-mode-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-primary {
  flex: 1;
  padding: 0.8rem 1.5rem;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { 
  opacity: 0.5; 
  cursor: not-allowed; 
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  padding: 0.8rem 1.25rem;
  background: var(--card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: #ccc;
  color: var(--text);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

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

.result-section {
  margin-top: 1.5rem;
  animation: fadeInUp 0.4s ease;
}

.result-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(16, 185, 129, 0.2);
  transition: all 0.3s ease;
}

.result-card:hover {
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.15);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-bottom: 1px solid #a7f3d0;
}

.result-icon {
  width: 28px;
  height: 28px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.result-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #065f46;
}

.result-body {
  padding: 1.5rem 1.25rem;
}

.result-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.result-link-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.link-box {
  display: flex;
  gap: 0.5rem;
}

.link-box input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  color: var(--primary);
  background: #f8fafc;
  outline: none;
}

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

.btn-copy {
  padding: 0 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.btn-copy:hover { opacity: 0.9; }

.result-meta {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.btn-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem 1.5rem;
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn-preview:hover { opacity: 0.9; }

.error-section {
  margin-top: 1.5rem;
  animation: fadeInUp 0.3s ease;
}

.error-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-align: center;
}

.error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #fef2f2;
  color: var(--error);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.error-card p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.app-footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.progress-section {
  margin-top: 1.5rem;
  animation: fadeInUp 0.4s ease;
}

.progress-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-bottom: 1px solid #93c5fd;
}

.progress-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ai-pulse {
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

.progress-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e40af;
}

.progress-body {
  padding: 1.5rem 1.25rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  background-size: 200% 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
  animation: shimmer 2s linear infinite;
  width: 0%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #f8fafc;
  transition: all 0.3s ease;
}

.progress-step.active {
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  transform: translateX(4px);
}

.progress-step.completed {
  background: #f0fdf4;
  border-left: 3px solid #22c55e;
}

.step-icon {
  width: 24px;
  height: 24px;
  background: #e5e7eb;
  color: #6b7280;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.3s ease;
}

.progress-step.active .step-icon {
  background: #3b82f6;
  color: #fff;
  animation: pulse 1.5s ease-in-out infinite;
}

.progress-step.completed .step-icon {
  background: #22c55e;
  color: #fff;
}

.progress-step.completed .step-icon::after {
  content: '✓';
  font-size: 0.7rem;
}

.step-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.progress-step.active .step-text {
  color: #1e40af;
  font-weight: 600;
}

.progress-step.completed .step-text {
  color: #166534;
}

.progress-message {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #e5e7eb;
}

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

@media (max-width: 640px) {
  .app-header { padding: 1.5rem 0 1rem; }
  .logo h1 { font-size: 1.3rem; }
  .editor-textarea { min-height: 250px; padding: 1rem; }
  .editor-actions { flex-direction: column; }
  .btn-primary, .btn-preview { width: 100%; }
  .result-actions { flex-direction: column; }
  .link-box { flex-direction: column; }
  .link-box input { font-size: 0.8rem; }
  .style-mode-selector { flex-direction: column; gap: 0.5rem; }
  .style-mode-btns { flex-wrap: wrap; }
}
