:root {
  --blue-dark: #1e3a8a;
  --blue-mid: #2563eb;
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --red: #dc2626;
  --green: #16a34a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
  min-height: 100vh;
  color: var(--gray-900);
  line-height: 1.5;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
}

.header {
  text-align: center;
  color: var(--white);
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.subtitle {
  opacity: 0.9;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.steps {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.2s;
}

.step-dot.active {
  background: var(--white);
}

.step-label {
  font-size: 0.85rem;
  opacity: 0.85;
}

.main {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  padding: 2rem;
}

.step-panel {
  display: none;
}

.step-panel.active {
  display: block;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.divider {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--blue-mid);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

#btn-scrape {
  margin-top: 0.5rem;
}

.form-actions {
  margin-top: 1.5rem;
}

.form-actions .btn {
  width: 100%;
  padding: 0.75rem;
}

.status {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  color: var(--gray-500);
}

.status.success {
  color: var(--green);
}

.status.error {
  color: var(--red);
}

.loading-box {
  text-align: center;
  padding: 3rem 2rem;
}

.loading-text {
  font-size: 1.1rem;
  color: var(--gray-700);
  margin-bottom: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.success-msg {
  color: var(--green);
  font-weight: 500;
  margin-right: auto;
}

.preview-frame-wrap {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  background: var(--gray-50);
  min-height: 400px;
}

#preview-frame {
  width: 100%;
  height: 70vh;
  min-height: 400px;
  border: none;
  display: block;
}

.success-box {
  padding: 0.5rem 0;
}

.success-box h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--gray-900);
}

.url-group {
  margin-bottom: 1rem;
}

.url-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.url-row {
  display: flex;
  gap: 0.5rem;
}

.url-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.9rem;
}

.url-row .btn {
  flex-shrink: 0;
}

.success-box #btn-copy-both {
  margin-right: 0.5rem;
  margin-top: 0.5rem;
}

.success-box #btn-another {
  margin-top: 1rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 0.6rem 1.25rem;
  background: var(--gray-900);
  color: var(--white);
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 100;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1.5rem;
  background: var(--red);
  color: var(--white);
  font-size: 0.9rem;
  text-align: center;
  display: none;
  z-index: 99;
}

.error-banner.show {
  display: block;
}
