:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-border: #e2e8f0;
  --bg-input: #ffffff;
  --input-border: #cbd5e1;
  --input-focus: #0f172a;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --accent-primary: #0f172a;
  --accent-primary-hover: #1e293b;
  --accent-glow: rgba(15, 23, 42, 0.12);
  --accent-emerald: #059669;
  --accent-emerald-bg: #ecfdf5;
  --accent-emerald-border: #a7f3d0;
  --accent-cyan: #0284c7;
  --accent-cyan-bg: #f0f9ff;
  --accent-cyan-border: #bae6fd;
  --accent-amber: #d97706;
  --accent-amber-bg: #fffbeb;
  --accent-amber-border: #fde68a;
  --btn-secondary: #f1f5f9;
  --btn-secondary-hover: #e2e8f0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 14px 28px -4px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  padding: 24px 16px 60px;
}

/* Ambient glow (Soft pastel light gradient) */
.bg-glow {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 450px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.08) 0%, rgba(16, 185, 129, 0.06) 40%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  width: 100%;
  max-width: 680px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Top Nav */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(5, 150, 105, 0.4);
}

.logo-text {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.user-tag {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald-border);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* Header */
.header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--accent-emerald-bg);
  border: 1px solid var(--accent-emerald-border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-emerald);
}

.badge-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-emerald);
}

.header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text-main);
}

.gradient-text {
  background: linear-gradient(135deg, #0f172a 0%, #0369a1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 480px;
  line-height: 1.5;
}

/* Notice Box */
.notice-box {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.4;
}

.notice-guest {
  background: var(--accent-amber-bg);
  border: 1px solid var(--accent-amber-border);
  color: #92400e;
}

.notice-guest a {
  color: #b45309;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.notice-logged-in {
  background: var(--accent-emerald-bg);
  border: 1px solid var(--accent-emerald-border);
  color: #065f46;
}

.notice-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Main Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.shorten-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
}

.label-muted {
  font-weight: 400;
  color: var(--text-dim);
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0 14px;
  transition: all 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.input-icon {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  margin-right: 10px;
  flex-shrink: 0;
}

.domain-prefix {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 15px;
  margin-right: 4px;
  font-weight: 700;
}

.input-wrapper input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 12px 0;
}

.input-wrapper input::placeholder {
  color: var(--text-dim);
}

.custom-slug-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
  font-family: var(--font-main);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  height: 36px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  padding: 12px 24px;
  height: 48px;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: var(--btn-secondary);
  color: var(--text-main);
  border: 1px solid var(--bg-card-border);
  padding: 10px 14px;
  height: 42px;
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: #cbd5e1;
}

.action-icon {
  width: 16px;
  height: 16px;
}

/* Result Box */
.result-box {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}

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

.result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.badge-tag {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.badge-perm {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald-border);
}

.badge-temp {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber-border);
}

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

.short-url-input {
  flex: 1;
  background: #f8fafc;
  border: 1px solid var(--input-border);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  outline: none;
}

.result-actions {
  display: flex;
  gap: 8px;
}

/* QR code container */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f8fafc;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  margin-top: 6px;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}

.qr-canvas {
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--bg-card-border);
  border-radius: 10px;
  display: inline-block;
  box-shadow: var(--shadow-sm);
}

.qr-canvas img, .qr-canvas canvas {
  display: block;
}

.qr-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.qr-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* History Section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.history-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge-counter {
  font-size: 0.8rem;
  background: var(--btn-secondary);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--bg-card-border);
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-item {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.link-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.link-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  max-width: 54%;
}

.link-short-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-short-url {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: #0284c7;
  text-decoration: none;
}

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

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

.link-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.clicks-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  background: var(--accent-cyan-bg);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-cyan-border);
}

.btn-icon-only {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon-only:hover {
  color: var(--text-main);
  background: var(--btn-secondary);
}

.btn-icon-only.btn-analytics:hover {
  color: #0284c7;
  background: var(--accent-cyan-bg);
}

.btn-icon-only.btn-qr:hover {
  color: var(--accent-emerald);
  background: var(--accent-emerald-bg);
}

.btn-delete:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px dashed var(--bg-card-border);
  border-radius: var(--radius-md);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
}

.modal-card.modal-sm {
  max-width: 380px;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-qr-body {
  align-items: center;
  text-align: center;
}

.qr-modal-url {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #0284c7;
  word-break: break-all;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.auth-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: #f8fafc;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stat-num.stat-text-sm {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
  word-break: break-word;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Analytics Breakdowns */
.analytics-breakdowns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.breakdown-box {
  background: #f8fafc;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.breakdown-box h4, .activity-log-box h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.breakdown-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.breakdown-name {
  color: var(--text-main);
}

.breakdown-val {
  color: #0284c7;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* Activity Log */
.activity-log-box {
  background: #f8fafc;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.activity-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
}

.log-meta {
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.log-badge {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.log-time {
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 300;
}

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

/* Footer */
.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 10px;
}

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

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

/* Responsive */
@media (max-width: 600px) {
  .custom-slug-row {
    flex-direction: column;
    align-items: stretch;
  }
  .header h1 {
    font-size: 1.75rem;
  }
  .result-row {
    flex-direction: column;
    align-items: stretch;
  }
  .result-actions {
    justify-content: flex-end;
  }
  .analytics-breakdowns {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .link-info {
    max-width: 44%;
  }
}
