/* === Base Reset & Variables === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f8f9fc;
  --fg: #1a1d2e;
  --card: #ffffff;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-fg: #ffffff;
  --secondary: #f0f1f5;
  --secondary-fg: #2d3148;
  --muted: #9ca3af;
  --border: #e5e7eb;
  --accent: #06b6d4;
  --destructive: #ef4444;
  --success: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Sora', sans-serif;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* === Homepage === */
.home-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.home-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.home-center {
  width: 100%;
  max-width: 560px;
  text-align: center;
}

.logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}

.logo-icon svg {
  width: 36px;
  height: 36px;
}

.logo-text {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.text-indigo { color: #6366f1; }
.text-cyan { color: #06b6d4; }

.tagline {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* Search Box */
.search-form {
  margin-bottom: 1.25rem;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon-left {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 14px 56px 14px 48px;
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--fg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-input::placeholder {
  color: var(--muted);
}

.search-btn-inline {
  position: absolute;
  right: 8px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.search-btn-inline:hover {
  background: var(--primary-hover);
}

.search-btn-inline svg {
  width: 18px;
  height: 18px;
}

/* Buttons */
.home-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 2rem;
}

.btn-primary {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.btn-outline {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-outline:hover {
  background: var(--secondary);
}

.btn-ghost {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.btn-ghost:hover {
  color: var(--fg);
  background: var(--secondary);
}

/* Shortlinks */
.shortlinks-wrap {
  padding-top: 0.5rem;
}

.shortlinks-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.shortlinks-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.shortlink-tag {
  padding: 6px 14px;
  font-size: 0.85rem;
  background: var(--secondary);
  color: var(--secondary-fg);
  border-radius: var(--radius-sm);
  text-transform: capitalize;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
}

.shortlink-tag:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  text-decoration: none;
}

/* Footer */
.home-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--fg);
}

/* === Redirect Page === */
.redirect-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.redirect-box {
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.redirect-text {
  color: var(--muted);
  font-size: 1rem;
}

.redirect-error {
  color: var(--destructive);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.back-link {
  font-size: 0.9rem;
  color: var(--primary);
}

/* === Search Results === */
.search-results {
  text-align: left;
  margin-bottom: 1.5rem;
}

.results-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-align: center;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.result-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
  text-decoration: none;
}

.result-card-left {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.result-url {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 12px;
}

.result-slug {
  font-size: 0.75rem;
  font-family: monospace;
  background: var(--secondary);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--primary);
}

.result-arrow {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.results-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2rem 0;
}

/* === Responsive === */
@media (max-width: 480px) {
  .logo-text {
    font-size: 2rem;
  }
  .home-buttons {
    flex-direction: column;
  }
  .btn-primary, .btn-secondary {
    width: 100%;
  }
  .result-card-right .result-slug {
    display: none;
  }
}