:root {
  --bg-1: #4f46e5;
  --bg-2: #7c3aed;
  --surface: #ffffff;
  --text: #1e1b2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px -15px rgba(79, 70, 229, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  padding: 24px 16px;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
}

.hero {
  text-align: center;
  color: #fff;
  margin-bottom: 24px;
  padding-top: 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  background: #f3f4f6;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: 8px;
}

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

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

.panel {
  display: none;
  padding: 24px 20px 20px;
}

.panel.active {
  display: block;
}

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

.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fafafa;
}

input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: #fff;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.7; cursor: default; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error {
  margin: 10px 2px 0;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.result {
  margin-top: 20px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  animation: fade-in 0.2s ease;
}

.result-label {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-row a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
}

.result-row a:hover { text-decoration: underline; }

.icon-btn {
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  background: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: #f9fafb;
  border-color: var(--primary);
}

.recent {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.recent-label {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.link-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin-bottom: 10px;
}

.link-btn:hover { color: var(--error); }

#recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#recent-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 0.85rem;
}

#recent-list a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
}

#recent-list a:hover { text-decoration: underline; }

.recent-original {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  text-align: right;
}

.stats-result {
  margin-top: 20px;
  animation: fade-in 0.2s ease;
}

.stat-tile {
  text-align: center;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 28px 16px;
  margin-bottom: 16px;
}

.stat-number {
  display: block;
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-caption {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-details {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stats-details > div {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.stats-details > div:last-child { border-bottom: none; }

.stats-details dt {
  flex-shrink: 0;
  width: 90px;
  color: var(--text-muted);
  font-weight: 600;
}

.stats-details dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.stats-details a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.stats-details a:hover { text-decoration: underline; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer {
  text-align: center;
  margin-top: 24px;
  padding-bottom: 24px;
}

.footer p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.8rem;
}

.btn-link {
  display: inline-block;
  margin-top: 4px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: #1e1b2e;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 420px) {
  .input-row {
    flex-direction: column;
  }
  .btn-primary {
    padding: 13px 20px;
  }
  .stat-number {
    font-size: 2.25rem;
  }
  .stats-details dt {
    width: 76px;
    font-size: 0.78rem;
  }
}
