:root {
  --bg-dark: #080b12;
  --card-bg: rgba(15, 23, 42, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --cyan: #38bdf8;
  --cyan-hover: #7dd3fc;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --green: #10b981;
  --radius: 16px;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Background ambient light */
.glow-bg {
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.18) 0%, rgba(99, 102, 241, 0.08) 60%, transparent 80%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: blur(80px);
  z-index: 0;
}

.wrapper {
  width: 100%;
  max-width: 580px;
  position: relative;
  z-index: 1;
}

.mask-box {
  background: var(--card-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
}

.brand h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  align-items: center;
  background: rgba(2, 6, 23, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
}

.input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  padding: 10px 0;
  font-family: 'Inter', sans-serif;
}

.btn-paste {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-paste:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.dest-group {
  display: none;
}

.dest-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-auto {
  color: var(--cyan);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
}

.slug-row {
  display: flex;
  align-items: center;
  background: rgba(2, 6, 23, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px 14px;
  transition: border-color 0.2s;
}

.slug-row:focus-within {
  border-color: var(--cyan);
}

.slug-domain {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
  -webkit-user-select: none;
  user-select: none;
}

.slug-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  padding: 10px 6px;
  font-family: 'Inter', sans-serif;
}

.btn-mask {
  width: 100%;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 60%, #6366f1 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  margin-top: 24px;
}

.btn-mask:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.5);
}

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

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

.quick-test {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.test-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--cyan);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.test-pill:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--cyan);
}

/* Result Card */
.result-card {
  margin-top: 26px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

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

.result-card.hidden {
  display: none;
}

.result-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.green-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--green);
}

.result-url-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  word-break: break-all;
}

.masked-url-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--cyan);
}

.result-buttons {
  display: flex;
  gap: 10px;
}

.btn-res {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-res.primary {
  background: var(--cyan);
  color: #0b1120;
}

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

.btn-res.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-res.secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  border: 1px solid var(--cyan);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 999;
}

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

/* Helpers */
.hidden {
  display: none !important;
}

/* Login Card Styles */
.login-box {
  max-width: 440px;
  margin: 0 auto;
}

.brand.center {
  flex-direction: column;
  text-align: center;
  gap: 12px;
}

.lock-icon {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
}

.login-error {
  margin-top: 8px;
  color: #f87171;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Header with Logout */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* History Box */
.history-box {
  margin-top: 24px;
  padding: 24px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.history-title-row h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.badge-count {
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.history-search-row {
  margin-bottom: 16px;
}

.history-search-row input {
  width: 100%;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: #fff;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
}

.history-search-row input:focus {
  border-color: var(--cyan);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.history-item {
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, background 0.2s;
}

.history-item:hover {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(2, 6, 23, 0.85);
}

.history-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-short-url {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan);
  text-decoration: none;
  word-break: break-all;
}

.history-short-url:hover {
  text-decoration: underline;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-mini:hover {
  background: var(--cyan);
  color: #0b1120;
  border-color: var(--cyan);
}

.history-target-url {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.history-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 6px;
  margin-top: 2px;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-clicks {
  color: #34d399;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-date {
  color: var(--text-dim);
}

.history-empty, .history-loading {
  text-align: center;
  padding: 30px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner.inline {
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

/* Mode Selector Styles */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 600px) {
  .mode-selector {
    grid-template-columns: 1fr;
  }
}

.mode-option {
  position: relative;
  cursor: pointer;
  display: block;
}

.mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-box {
  background: rgba(2, 6, 23, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 14px;
  transition: all 0.2s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mode-option:hover .mode-box {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.85);
}

.mode-option input[type="radio"]:checked + .mode-box {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.mode-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.mode-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

