:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --card-bg: rgba(255, 255, 255, 0.96);
  --text: #1a1a2e;
  --muted: #6b7280;
  --accent: #7c3aed;
  --accent-2: #4f46e5;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success-bg: #f5f3ff;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

.page-header {
  text-align: center;
  color: #fff;
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 2.1rem;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.tabs {
  display: flex;
  gap: 4px;
  background: #f1f0f8;
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab.active {
  background: #fff;
  color: var(--accent-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tab-panel.hidden {
  display: none;
}

.dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: #faf9ff;
}

.dropzone-empty svg {
  color: var(--accent);
  margin-bottom: 8px;
}

.dropzone-empty p {
  margin: 4px 0;
  font-size: 0.92rem;
}

.dropzone-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: contain;
}

.dropzone-preview.hidden,
.dropzone-empty.hidden {
  display: none;
}

.file-meta {
  margin-top: 8px;
  font-size: 0.85rem;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.82rem;
  margin-top: 6px;
  text-decoration: underline;
}

.field {
  margin-top: 18px;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.text-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.hint {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

.url-preview-wrap {
  margin-top: 12px;
}

.url-preview-wrap img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: contain;
}

.submit-btn {
  width: 100%;
  margin-top: 24px;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}

.submit-btn:hover {
  transform: translateY(-1px);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.result-card {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-idle {
  text-align: center;
  padding: 60px 20px;
}

.result-loading {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #eee;
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

.result-error {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 18px;
}

.error-title {
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--danger);
}

.error-message {
  margin: 0;
  color: #7f1d1d;
  font-size: 0.9rem;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.compare-item {
  text-align: center;
}

.compare-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.compare-item img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 10px;
  background: repeating-conic-gradient(#f3f3f3 0% 25%, #fafafa 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border);
}

.url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.url-row .text-input {
  flex: 1;
  font-size: 0.82rem;
  background: #f9fafb;
}

.secondary-btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.secondary-btn:hover {
  background: #f5f3ff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat {
  background: var(--success-bg);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 700;
}

.raw-details {
  margin-top: 12px;
  font-size: 0.82rem;
}

.raw-details summary {
  cursor: pointer;
  color: var(--accent-2);
  font-weight: 600;
}

.raw-details pre {
  margin-top: 10px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.78rem;
  max-height: 260px;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}
