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

:root {
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --accent-color: #f093fb;
  --bg-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  --card-bg: rgba(255, 255, 255, 0.1);
  --card-border: rgba(255, 255, 255, 0.2);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --text-primary: #333;
  --text-secondary: #666;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --border-radius: 15px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --blur: 20px;
}

body.dark-mode {
  --primary-color: #8b5cf6;
  --secondary-color: #d946ef;
  --accent-color: #f5576c;
  --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --text-primary: #fff;
  --text-secondary: #ccc;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-primary);
  transition: background 0.3s, color 0.3s;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border-radius: var(--border-radius);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  animation: fadeInUp 0.6s ease-out;
}

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

.header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 15px;
  align-items: center;
}

.theme-toggle {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.add-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.add-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

.links-container {
  width: 100%;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  padding: 20px;
}

.link-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border-radius: var(--border-radius);
  padding: 25px;
  border: 1px solid var(--glass-border);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--glass-shadow);
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;
}

.link-card:nth-child(1) { animation-delay: 0.1s; }
.link-card:nth-child(2) { animation-delay: 0.2s; }
.link-card:nth-child(3) { animation-delay: 0.3s; }
.link-card:nth-child(4) { animation-delay: 0.4s; }
.link-card:nth-child(5) { animation-delay: 0.5s; }
.link-card:nth-child(6) { animation-delay: 0.6s; }
.link-card:nth-child(7) { animation-delay: 0.7s; }
.link-card:nth-child(8) { animation-delay: 0.8s; }
.link-card:nth-child(9) { animation-delay: 0.9s; }
.link-card:nth-child(10) { animation-delay: 1s; }

.link-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.link-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border-color: rgba(102, 126, 234, 0.6);
}

.link-card:hover::before {
  transform: scaleX(1);
}

.link-card:hover .link-icon {
  transform: scale(1.1) rotate(5deg);
}

.link-card:hover .link-info h3 {
  transform: translateY(-4px);
  text-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.link-card:hover .link-info p {
  opacity: 1;
  transform: translateY(-2px);
}

.link-card:active {
  transform: translateY(-6px) scale(0.98);
}

.link-card.clicked {
  animation: clickEffect 0.3s ease-in-out;
}

.link-card.dragging {
  opacity: 0.5;
  transform: scale(1.05) rotate(2deg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.link-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
}

.link-card:hover .link-icon {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.link-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.link-card:hover .link-icon img {
  transform: scale(1.1);
}

.link-info {
  text-align: center;
  margin-bottom: 20px;
}

.link-info h3 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  transition: var(--transition);
}

.link-card:hover .link-info h3 {
  transform: translateY(-2px);
}

.link-info p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-all;
  transition: var(--transition);
}

.link-card:hover .link-info p {
  opacity: 0.9;
}

.link-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: var(--transition);
}

.link-card:hover .link-actions {
  opacity: 1;
  transform: translateY(0);
}

.link-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-btn {
  background: rgba(102, 126, 234, 0.2);
  color: #667eea;
}

.preview-btn:hover {
  background: rgba(102, 126, 234, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.edit-btn {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

.edit-btn:hover {
  background: rgba(52, 211, 153, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 211, 153, 0.3);
}

.delete-btn {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--glass-shadow);
  animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--glass-border);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

body.dark-mode .modal-content {
  background: rgba(30, 30, 50, 0.95);
}

.auto-filled {
  animation: pulse 0.6s ease-in-out;
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2) !important;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.preview-content {
  max-width: 1200px;
  width: 95%;
  animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-container {
  width: 100%;
  height: 70vh;
  padding: 25px;
  animation: fadeIn 0.6s ease-out;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: zoomIn 0.6s ease-out;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.close-btn:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.1);
  transform: rotate(90deg);
}

body.dark-mode .close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-content form {
  padding: 25px;
}

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

.form-group label {
  display: block;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.dark-mode .form-group input {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.1);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 25px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .modal-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.cancel-btn,
.submit-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cancel-btn {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

body.dark-mode .cancel-btn {
  background: rgba(255, 255, 255, 0.1);
}

.cancel-btn:hover {
  background: rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode .cancel-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.submit-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.preview-container {
  width: 100%;
  height: 70vh;
  padding: 25px;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  animation: slideIn 0.3s ease-out;
  font-size: 16px;
  font-weight: 500;
  color: white;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification.success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.notification.error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.notification.warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

@keyframes clickEffect {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 1024px) {
  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header {
    padding: 15px;
    flex-direction: column;
    gap: 15px;
  }

  .header h1 {
    font-size: 24px;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
    gap: 12px;
  }

  .theme-toggle {
    padding: 10px 14px;
    font-size: 18px;
  }

  .add-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    padding: 10px;
  }

  .link-card {
    padding: 18px;
  }

  .link-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 15px;
  }

  .link-info h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .link-info p {
    font-size: 12px;
  }

  .link-actions {
    opacity: 1;
    transform: translateY(0);
    flex-wrap: wrap;
    gap: 6px;
  }

  .link-actions button {
    padding: 6px 12px;
    font-size: 12px;
  }

  .modal-content {
    width: 95%;
    margin: 10px;
  }

  .modal-header {
    padding: 20px;
  }

  .modal-header h2 {
    font-size: 20px;
  }

  .modal-content form {
    padding: 20px;
  }

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

  .form-group input {
    padding: 12px 16px;
    font-size: 14px;
  }

  .modal-footer {
    padding: 20px;
    gap: 10px;
  }

  .cancel-btn,
  .submit-btn {
    padding: 10px 24px;
    font-size: 14px;
  }

  .preview-container {
    height: 60vh;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .link-card {
    padding: 15px;
  }

  .link-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
  }

  .link-info h3 {
    font-size: 14px;
    margin-bottom: 6px;
  }

  .link-info p {
    font-size: 11px;
  }

  .link-actions button {
    padding: 5px 10px;
    font-size: 11px;
  }
}